diff --git a/web/src/list_widget.ts b/web/src/list_widget.ts index 423411d329..708e2ad627 100644 --- a/web/src/list_widget.ts +++ b/web/src/list_widget.ts @@ -586,8 +586,9 @@ export function handle_sort($th: JQuery, list: ListWidget) */ - 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.js index bc13b50f2b..f932894e16 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), }),