typeahead: Clean up render function.

`final_items` is a list of `ItemType` so it doesn't
make sense to wrap it in `$()`. Intead of creating a
"jquery list of objects", we generate a list of JQuery
objects. I also removed the unused `_index` in the
`map` call.
This commit is contained in:
evykassirer 2024-03-18 12:34:17 -07:00 committed by Tim Abbott
parent 6aee4f270e
commit 3f5be23854
1 changed files with 3 additions and 3 deletions

View File

@ -350,7 +350,7 @@ Typeahead.prototype = {
},
render(final_items, matching_items) {
const $items = $(final_items).map((_index, item) => {
const $items = final_items.map((item) => {
const $i = $(ITEM_HTML).data("typeahead-value", item);
const item_html = this.highlighter_html(item);
const $item_html = $i.find("a").html(item_html);
@ -360,10 +360,10 @@ Typeahead.prototype = {
if (option_label_html) {
$item_html.append(option_label_html).addClass("typeahead-option-label");
}
return $i[0];
return $i;
});
$items.first().addClass("active");
$items[0].addClass("active");
this.$menu.empty().append($items);
return this;
},