Skip to content

Commit

Permalink
fix: init caused filter ti not initialized commented code causing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Dec 14, 2024
1 parent f7c7915 commit 87fc647
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,31 @@ const selector =
"[filter-selector], [filter-closest], [filter-parent], [filter-next], [filter-previous], [filter-key], [filter-query-key], [filter-search], [filter-sort-key], [filter-on], [filter-limit], [filter-index]";

async function init(element) {
if (!element) {
element = document.querySelectorAll(selector);
for (let i = 0; i < element.length; i++) {
await initElement(element[i]);
}
} else {
if (
!(element instanceof HTMLCollection) &&
!(element instanceof NodeList) &&
!Array.isArray(element)
) {
element = [element];
}
for (let i = 0; i < element.length; i++) {
if (element[i].matches(selector)) {
await initElement(element[i]);
}
}
element = document.querySelectorAll(selector);
for (let i = 0; i < element.length; i++) {
await initElement(element[i]);
}

// if (!element) {
// element = document.querySelectorAll(selector);
// for (let i = 0; i < element.length; i++) {
// await initElement(element[i]);
// }
// } else {
// if (
// !(element instanceof HTMLCollection) &&
// !(element instanceof NodeList) &&
// !Array.isArray(element)
// ) {
// element = [element];
// }
// for (let i = 0; i < element.length; i++) {
// if (element[i].matches(selector)) {
// await initElement(element[i]);
// }
// }
// }

return true;
}

Expand Down

0 comments on commit 87fc647

Please sign in to comment.