Skip to content

Commit

Permalink
perf(mark): improve marking logic to avoid error #196
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Mar 1, 2024
1 parent 1d02fa7 commit 7f92b81
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/auro-menu.js
Expand Up @@ -127,24 +127,26 @@ export class AuroMenu extends LitElement {
* @returns {void} When called will update the DOM with visible suggest text matches.
*/
markOptions() {
let itemsToMark = []; // eslint-disable-line prefer-const
if (this.items && this.items.length > 0) {
let itemsToMark = []; // eslint-disable-line prefer-const

this.items.forEach((item) => {
if (this.optionInteractive(item) && !item.hasAttribute('persistent')) {
itemsToMark.push(item);
}
});
this.items.forEach((item) => {
if (this.optionInteractive(item) && !item.hasAttribute('persistent')) {
itemsToMark.push(item);
}
});

const markInstance = new Mark(itemsToMark); // eslint-disable-line
const markInstance = new Mark(itemsToMark); // eslint-disable-line

markInstance.unmark();
markInstance.unmark();

if (this.matchWord && this.matchWord.length > 0) {
markInstance.mark(this.matchWord, {
'element': 'strong',
'separateWordSearch': false,
'acrossElements': true
});
if (this.matchWord && this.matchWord.length > 0) {
markInstance.mark(this.matchWord, {
'element': 'strong',
'separateWordSearch': false,
'acrossElements': true
});
}
}
}

Expand Down

0 comments on commit 7f92b81

Please sign in to comment.