@daz4126/helium 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/helium.js +5 -6
- package/package.json +1 -1
package/helium.js
CHANGED
|
@@ -8,7 +8,11 @@ let HELIUM = null;
|
|
|
8
8
|
window.helium = function() {
|
|
9
9
|
let initFn;
|
|
10
10
|
const ALL = Symbol("all");
|
|
11
|
-
const he = (n,...a) =>
|
|
11
|
+
const he = (n,...a) => {
|
|
12
|
+
const prefix = n.split(/[.:]/)[0];
|
|
13
|
+
if (prefix === ":" || prefix === "") return false;
|
|
14
|
+
return a.map(b => `|@${b}|data-he-${b}|`).join``.includes(`|${prefix}|`);
|
|
15
|
+
};
|
|
12
16
|
const root = document.querySelector("[\\@helium]") || document.querySelector("[data-helium]") || document.body;
|
|
13
17
|
|
|
14
18
|
// Initialize or reuse HELIUM object
|
|
@@ -104,7 +108,6 @@ function applyBinding(b,e={},elCtx=b.el){
|
|
|
104
108
|
? Idiomorph.morph(el, content,{morphStyle:'innerHTML'})
|
|
105
109
|
: el.innerHTML = content;
|
|
106
110
|
}
|
|
107
|
-
|
|
108
111
|
if (prop==="class" && r && typeof r==="object")
|
|
109
112
|
return Object.entries(r).forEach(([k,v]) =>
|
|
110
113
|
k.split(/\s+/).forEach(c => el.classList.toggle(c,v)));
|
|
@@ -254,10 +257,6 @@ function processElements(element) {
|
|
|
254
257
|
tracked.forEach(key => addBinding(key, {el, prop: null, fn}));
|
|
255
258
|
})
|
|
256
259
|
}
|
|
257
|
-
else if (he(name, "class")) {
|
|
258
|
-
const fn = compile(value, true);
|
|
259
|
-
deferredBindings.push(() => trackDependencies(fn, el).forEach(dep => addBinding(dep, {el, prop: "class", fn})));
|
|
260
|
-
}
|
|
261
260
|
else if (he(name, "init")) {
|
|
262
261
|
initFn = compile(value, true);
|
|
263
262
|
}
|