zjquery: Add set_height helper.

This commit is contained in:
Steve Howell 2021-02-08 15:27:29 +00:00 committed by Steve Howell
parent e93a4313f3
commit 31f7f26a22
3 changed files with 14 additions and 2 deletions

View File

@ -31,7 +31,7 @@ function init_simulated_scrolling() {
$("#buddy_list_wrapper")[0] = elem;
$("#buddy_list_wrapper_padding").height = () => 0;
$("#buddy_list_wrapper_padding").set_height(0);
return elem;
}

View File

@ -223,6 +223,8 @@ run_test("start", () => {
abort_xhr_called = true;
};
$("#compose-textarea").set_height(50);
assert_hidden("#compose_controls");
cancel();
assert(abort_xhr_called);

View File

@ -152,6 +152,8 @@ exports.make_new_elem = function (selector, opts) {
let value;
let css;
let shown = false;
let height;
const find_results = new Map();
let my_parent;
const parents_result = new Map();
@ -234,7 +236,12 @@ exports.make_new_elem = function (selector, opts) {
hasClass(class_name) {
return classes.has(class_name);
},
height: noop,
height() {
if (height === undefined) {
throw new Error(`Please call $("${selector}").set_height`);
}
return height;
},
hide() {
shown = false;
return self;
@ -325,6 +332,9 @@ exports.make_new_elem = function (selector, opts) {
serializeArray() {
return self;
},
set_height(fake_height) {
height = fake_height;
},
set_parent(parent_elem) {
my_parent = parent_elem;
},