list_widget: Convert .data("sort"), .data("sort-prop") to .attr.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-05-02 18:00:11 -07:00 committed by Tim Abbott
parent 382eec17e2
commit 7a5e68161a
2 changed files with 9 additions and 8 deletions

View File

@ -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")) {

View File

@ -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),
}),