From 87fc647dbcf48af69557678543a7f246bf15e1c0 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Sat, 14 Dec 2024 16:39:51 -0600 Subject: [PATCH] fix: init caused filter ti not initialized commented code causing issue --- src/index.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/index.js b/src/index.js index 4c2940c..ab24d41 100644 --- a/src/index.js +++ b/src/index.js @@ -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; }