Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
list_widget: Convert .data("sort"), .data("sort-prop") to .attr.
Anders Kaseorg7a5e68161aea
diff --git a/web/src/list_widget.ts b/web/src/list_widget.tsindex 423411d329e..708e2ad6273 100644--- a/web/src/list_widget.ts+++ b/web/src/list_widget.ts@@ -586,8 +586,9 @@ export function handle_sort<Key, Item>($th: JQuery, list: ListWidget<Key, Item>)<th data-sort="status"></th></thead>*/- const sort_type: string = $th.data("sort");- const prop_name: string = $th.data("sort-prop");+ const sort_type = $th.attr("data-sort");+ const prop_name = $th.attr("data-sort-prop");+ assert(sort_type !== undefined);if ($th.hasClass("active")) {if (!$th.hasClass("descend")) {diff --git a/web/tests/list_widget.test.js b/web/tests/list_widget.test.jsindex bc13b50f2b4..f932894e16e 100644--- a/web/tests/list_widget.test.js+++ b/web/tests/list_widget.test.js@@ -315,15 +315,15 @@ function sort_button(opts) {// don't have any abstraction for the button and its// siblings other than direct jQuery actions.- function data(sel) {- switch (sel) {- case "sort":+ function attr(name) {+ switch (name) {+ case "data-sort":return opts.sort_type;- case "sort-prop":+ case "data-sort-prop":return opts.prop_name;/* istanbul ignore next */default:- throw new Error("unknown selector: " + sel);+ throw new Error("unknown attribute: " + name);}}@@ -337,7 +337,7 @@ function sort_button(opts) {const classList = new Set();const $button = {- data,+ attr,closest: lookup(".progressive-table-wrapper", {data: lookup("list-widget", opts.list_name),}),