@ecl/dom-utils
Advanced tools
Comparing version 3.2.4 to 3.3.0
@@ -9,2 +9,7 @@ import { queryAll } from '..'; | ||
const components = []; | ||
if (!ECL.components) { | ||
ECL.components = []; | ||
} | ||
const nodes = queryAll('[data-ecl-auto-init]', root); | ||
@@ -41,5 +46,4 @@ | ||
ECL.components.push(component); | ||
components.push(component); | ||
node.setAttribute('data-ecl-auto-initialized', 'true'); | ||
}); | ||
@@ -50,14 +54,10 @@ }; | ||
const destroy = () => { | ||
nodes | ||
.filter( | ||
(node) => node.getAttribute('data-ecl-auto-initialized') === 'true' | ||
) | ||
.forEach((node) => { | ||
const componentType = node.getAttribute('data-ecl-auto-init'); | ||
if (componentType && ECL[componentType] && ECL[componentType].destroy) { | ||
ECL[componentType].destroy(); | ||
node.removeAttribute('data-ecl-auto-initialized'); | ||
if (ECL.components) { | ||
for (let i = ECL.components.length - 1; i >= 0; i -= 1) { | ||
if (ECL.components[i].destroy) { | ||
ECL.components[i].destroy(); | ||
ECL.components.splice(i, 1); | ||
} | ||
}); | ||
} | ||
} | ||
}; | ||
@@ -64,0 +64,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"license": "EUPL-1.2", | ||
"version": "3.2.4", | ||
"version": "3.3.0", | ||
"description": "ECL DOM utilities", | ||
@@ -26,3 +26,3 @@ "main": "index.js", | ||
], | ||
"gitHead": "df0ed566a1a32496ba0988ed238d5be2ca2632fd" | ||
"gitHead": "c9a78d9b503a12271e599bb2f57006d87e2823a9" | ||
} |
18033