diff --git a/src/auro-menu.js b/src/auro-menu.js index f35b5f1..159428c 100644 --- a/src/auro-menu.js +++ b/src/auro-menu.js @@ -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 + }); + } } }