diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js index 8617d0b16c..d7be071c16 100644 --- a/frontend_tests/node_tests/activity.js +++ b/frontend_tests/node_tests/activity.js @@ -302,6 +302,7 @@ test("handlers", ({override, mock_template}) => { keys: [me.user_id, alice.user_id, fred.user_id], }); activity.set_cursor_and_filter(); + $("#user_presences").empty = () => {}; $me_li = $.create("me stub"); $alice_li = $.create("alice stub"); diff --git a/frontend_tests/node_tests/compose_validate.js b/frontend_tests/node_tests/compose_validate.js index a909bfb251..def46b662f 100644 --- a/frontend_tests/node_tests/compose_validate.js +++ b/frontend_tests/node_tests/compose_validate.js @@ -791,7 +791,7 @@ test_ui("test warn_if_topic_resolved", ({override, mock_template}) => { compose_validate.clear_topic_resolved_warning(); // Hack to make this empty for zjquery; this is conceptually done // in the previous line. - $error_area.html(""); + $error_area.empty(); assert.ok(!$error_area.visible()); compose_state.set_message_type("stream"); diff --git a/frontend_tests/node_tests/list_widget.js b/frontend_tests/node_tests/list_widget.js index 7e3f5d6fcd..dddf998b91 100644 --- a/frontend_tests/node_tests/list_widget.js +++ b/frontend_tests/node_tests/list_widget.js @@ -44,6 +44,7 @@ const ListWidget = zrequire("list_widget"); function make_container() { const $container = {}; + $container.empty = () => {}; // Make our append function just set a field we can // check in our tests. @@ -159,9 +160,6 @@ run_test("scrolling", () => { $simplebar_container: $scroll_container, }; - $container.html = (html) => { - assert.equal(html, ""); - }; ListWidget.create($container, items, opts); assert.deepEqual($container.$appended_data.html(), items.slice(0, 80).join("")); @@ -213,9 +211,6 @@ run_test("not_scrolling", () => { get_min_load_count, }; - $container.html = (html) => { - assert.equal(html, ""); - }; ListWidget.create($container, items, opts); assert.deepEqual($container.$appended_data.html(), items.slice(0, 80).join("")); @@ -251,9 +246,6 @@ run_test("filtering", () => { $simplebar_container: $scroll_container, }; - $container.html = (html) => { - assert.equal(html, ""); - }; const widget = ListWidget.create($container, list, opts); let expected_html = @@ -287,7 +279,6 @@ run_test("filtering", () => { run_test("no filtering", () => { const $container = make_container(); const $scroll_container = make_scroll_container(); - $container.html = () => {}; let callback_called = false; // Opts does not require a filter key. @@ -365,9 +356,6 @@ run_test("wire up filter element", () => { const $scroll_container = make_scroll_container(); const $filter_element = make_filter_element(); - // We don't care about what gets drawn initially. - $container.html = () => {}; - const opts = { filter: { filterer: (list, value) => list.filter((item) => item.toLowerCase().includes(value)), @@ -388,8 +376,7 @@ run_test("sorting", () => { const $sort_container = make_sort_container(); let cleared; - $container.html = (html) => { - assert.equal(html, ""); + $container.empty = () => { cleared = true; }; @@ -487,7 +474,6 @@ run_test("sorting", () => { run_test("custom sort", () => { const $container = make_container(); const $scroll_container = make_scroll_container(); - $container.html = () => {}; const n42 = {x: 6, y: 7}; const n43 = {x: 1, y: 43}; @@ -538,7 +524,6 @@ run_test("clear_event_handlers", () => { // We don't care about actual data for this test. const list = []; - $container.html = () => {}; const opts = { name: "list-we-create-twice", @@ -613,7 +598,6 @@ run_test("errors", () => { }); blueslip.reset(); - $container.html = () => {}; blueslip.expect("error", "List item is not a string: 999"); ListWidget.create($container, list, { modifier: () => 999, @@ -647,7 +631,6 @@ run_test("sort helpers", () => { run_test("replace_list_data w/filter update", () => { const $container = make_container(); const $scroll_container = make_scroll_container(); - $container.html = () => {}; const list = [1, 2, 3, 4]; let num_updates = 0; @@ -722,7 +705,6 @@ run_test("render item", () => { const $container = make_container(); const $scroll_container = make_scroll_container(); const INITIAL_RENDER_COUNT = 80; // Keep this in sync with the actual code. - $container.html = () => {}; let called = false; $scroll_container.find = (query) => { const expected_queries = [ @@ -840,7 +822,6 @@ run_test("Multiselect dropdown retain_selected_items", () => { const list = ["one", "two", "three", "four"].map((x) => ({name: x, value: x})); const data = ["one"]; // Data initially selected. - $container.html = () => {}; $container.find = (elem) => DropdownItem(elem); // We essentially create fake jQuery functions diff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.js index dfdd72e1b2..a12f0188df 100644 --- a/frontend_tests/node_tests/rendered_markdown.js +++ b/frontend_tests/node_tests/rendered_markdown.js @@ -359,7 +359,7 @@ run_test("spoiler-header-empty-fill", () => { // Test that an empty header gets the default text applied (through i18n filter). const toggle_button_html = '
'; - $header.html(""); + $header.empty(); rm.update_elements($content); assert.equal(toggle_button_html + "translated HTML: Spoiler
", $header.html()); }); diff --git a/frontend_tests/zjsunit/zjquery_element.js b/frontend_tests/zjsunit/zjquery_element.js index 6d8132af8c..529b78546d 100644 --- a/frontend_tests/zjsunit/zjquery_element.js +++ b/frontend_tests/zjsunit/zjquery_element.js @@ -59,6 +59,7 @@ function FakeElement(selector, opts) { empty(arg) { if (arg === undefined) { find_results.clear(); + html = ""; } return $self; }, diff --git a/static/js/buddy_list.js b/static/js/buddy_list.js index 4350872b05..ec9bd84033 100644 --- a/static/js/buddy_list.js +++ b/static/js/buddy_list.js @@ -59,7 +59,7 @@ export class BuddyList extends BuddyListConf { populate(opts) { this.render_count = 0; - this.$container.html(""); + this.$container.empty(); // We rely on our caller to give us items // in already-sorted order. diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js index fa8b4430f9..7b0d77cc0a 100644 --- a/static/js/emoji_picker.js +++ b/static/js/emoji_picker.js @@ -337,7 +337,7 @@ function round_off_to_previous_multiple(number_to_round, multiple) { } function reset_emoji_showcase() { - $(".emoji-showcase-container").html(""); + $(".emoji-showcase-container").empty(); } function update_emoji_showcase($focused_emoji) { diff --git a/static/js/lightbox.js b/static/js/lightbox.js index 97e7d6b8c7..c5cf3a6bb8 100644 --- a/static/js/lightbox.js +++ b/static/js/lightbox.js @@ -177,7 +177,7 @@ export function clear_for_testing() { export function render_lightbox_list_images(preview_source) { if (!is_open) { const images = Array.prototype.slice.call($(".focused_table .message_inline_image img")); - const $image_list = $("#lightbox_overlay .image-list").html(""); + const $image_list = $("#lightbox_overlay .image-list").empty(); for (const img of images) { const src = img.getAttribute("src"); diff --git a/static/js/list_widget.js b/static/js/list_widget.js index b069d3a97d..90ba95c07c 100644 --- a/static/js/list_widget.js +++ b/static/js/list_widget.js @@ -278,7 +278,7 @@ export function create($container, list, opts) { }; widget.clear = function () { - $container.html(""); + $container.empty(); meta.offset = 0; }; diff --git a/static/js/popovers.js b/static/js/popovers.js index 699e506873..7e220587e3 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -973,7 +973,7 @@ export function register_click_handlers() { emoji_name: "", emoji_code: "", success() { - $(".info_popover_actions #status_message").html(""); + $(".info_popover_actions #status_message").empty(); }, }); }); diff --git a/static/js/settings_account.js b/static/js/settings_account.js index b7aa73f531..9e9cc04501 100644 --- a/static/js/settings_account.js +++ b/static/js/settings_account.js @@ -286,7 +286,7 @@ export function add_custom_profile_fields_to_settings() { } const element_id = "#profile-settings .custom-profile-fields-form"; - $(element_id).html(""); + $(element_id).empty(); append_custom_profile_fields(element_id, people.my_current_user_id()); initialize_custom_user_type_fields(element_id, people.my_current_user_id(), true, true); diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.js index d7bc0002ce..31403ff8c3 100644 --- a/static/js/settings_profile_fields.js +++ b/static/js/settings_profile_fields.js @@ -153,7 +153,7 @@ function clear_form_data() { // Set default type "Short text" in field type dropdown $("#profile_field_type").val(field_types.SHORT_TEXT.id); // Clear data from select field form - $("#profile_field_choices").html(""); + $("#profile_field_choices").empty(); create_choice_row($("#profile_field_choices")); update_choice_delete_btn($("#profile_field_choices"), false); $("#profile_field_choices_row").hide(); @@ -314,7 +314,7 @@ function set_up_select_field_edit_form($profile_field_form, field_data) { // Re-render field choices in edit form to load initial select data const $choice_list = $profile_field_form.find(".edit_profile_field_choices_container"); $choice_list.off(); - $choice_list.html(""); + $choice_list.empty(); const choices_data = parse_field_choices_from_field_data(field_data); diff --git a/static/js/settings_user_groups.js b/static/js/settings_user_groups.js index bd7b4b1db6..b083644e83 100644 --- a/static/js/settings_user_groups.js +++ b/static/js/settings_user_groups.js @@ -31,7 +31,7 @@ export function reload() { } const $user_groups_section = $("#user-groups").expectOne(); - $user_groups_section.html(""); + $user_groups_section.empty(); populate_user_groups(); } diff --git a/static/js/settings_users.js b/static/js/settings_users.js index f8e73115d0..dd34a839b1 100644 --- a/static/js/settings_users.js +++ b/static/js/settings_users.js @@ -588,7 +588,7 @@ export function show_edit_user_info_modal(user_id, from_user_info_popover) { } const element = "#edit-user-form .custom-profile-field-form"; - $(element).html(""); + $(element).empty(); settings_account.append_custom_profile_fields(element, user_id); settings_account.initialize_custom_date_type_fields(element); fields_user_pills = settings_account.initialize_custom_user_type_fields( diff --git a/static/js/ui_init.js b/static/js/ui_init.js index 34bd10e4f8..eb4cf31cca 100644 --- a/static/js/ui_init.js +++ b/static/js/ui_init.js @@ -117,7 +117,7 @@ function message_unhover() { if ($current_message_hover === undefined) { return; } - $current_message_hover.find("span.edit_content").html(""); + $current_message_hover.find("span.edit_content").empty(); $current_message_hover = undefined; }