web: Convert .data("search-results-empty") to .attr.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-05-02 17:29:50 -07:00 committed by Tim Abbott
parent ebea1eed18
commit 153847d617
6 changed files with 13 additions and 8 deletions

View File

@ -83,7 +83,7 @@ export function searching(): boolean {
}
export function render_empty_user_list_message_if_needed($container: JQuery): void {
const empty_list_message = $container.data("search-results-empty");
const empty_list_message = $container.attr("data-search-results-empty");
if (!empty_list_message || $container.children().length) {
return;

View File

@ -291,8 +291,8 @@ export class BuddyList extends BuddyListConf {
}
}
$("#buddy-list-users-matching-view").data(
"search-results-empty",
$("#buddy-list-users-matching-view").attr(
"data-search-results-empty",
matching_view_empty_list_message,
);
if ($("#buddy-list-users-matching-view .empty-list-message").length) {
@ -302,7 +302,10 @@ export class BuddyList extends BuddyListConf {
$("#buddy-list-users-matching-view").html(empty_list_widget_html);
}
$("#buddy-list-other-users").data("search-results-empty", other_users_empty_list_message);
$("#buddy-list-other-users").attr(
"data-search-results-empty",
other_users_empty_list_message,
);
if ($("#buddy-list-other-users .empty-list-message").length) {
const empty_list_widget_html = render_empty_list_widget_for_list({
other_users_empty_list_message,

View File

@ -215,7 +215,7 @@ export function render_empty_list_message_if_needed(
): void {
let empty_list_message = $container.data("empty");
const empty_search_results_message = $container.data("search-results-empty");
const empty_search_results_message = $container.attr("data-search-results-empty");
if (filter_value && empty_search_results_message) {
empty_list_message = empty_search_results_message;
}

View File

@ -489,7 +489,8 @@ test("render_empty_user_list_message", ({override, mock_template}) => {
append($data) {
$appended_data = $data;
},
data() {
attr(name) {
assert.equal(name, "data-search-results-empty");
return empty_list_message;
},
children: () => [],

View File

@ -45,6 +45,7 @@ const ListWidget = zrequire("list_widget");
function make_container() {
const $container = {};
$container.attr = noop;
$container.empty = noop;
$container.data = noop;

View File

@ -10,10 +10,10 @@ const {realm} = require("./lib/zpage_params");
const fake_buddy_list = {
scroll_container_selector: "#whatever",
$users_matching_view_container: {
data() {},
attr() {},
},
$other_users_container: {
data() {},
attr() {},
},
find_li() {},
first_key() {},