Skip to content

Commit

Permalink
fix: Changed ES6 to ES5 style to make it compatible with al-folio's u…
Browse files Browse the repository at this point in the history
…glifier
  • Loading branch information
CheariX committed Jul 5, 2024
1 parent a3e48ee commit 3e9c2e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions assets/js/highlight-search-term.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const getTextNodesInElementContainingText = (element, text) => {
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
let node;
while ((node = walker.nextNode())) {
if (node.textContent?.toLowerCase().includes(text)) {
if (node.textContent && node.textContent.toLowerCase().includes(text)) {
nodes.push(node);
}
}
Expand All @@ -93,7 +93,8 @@ const getTextNodesInElementContainingText = (element, text) => {
// Fix: We changed this function to work on the node directly, rather than on its parent element.
const getRangesForSearchTermInNode = (node, search) => {
const ranges = [];
const text = node.textContent?.toLowerCase() || "";
const text = (node.textContent ? node.textContent.toLowerCase() : "") || "";

let start = 0;
let index;
while ((index = text.indexOf(search, start)) >= 0) {
Expand Down

0 comments on commit 3e9c2e5

Please sign in to comment.