mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-22 07:49:38 +01:00
🐛 update dom-common.js setDelete to setDeleteAttr
This commit is contained in:
parent
1df797e316
commit
78fdb45ea7
268
dist/dde-with-signals.js
vendored
268
dist/dde-with-signals.js
vendored
@ -1,19 +1,19 @@
|
|||||||
//deka-dom-el library is available via global namespace `dde`
|
//deka-dom-el library is available via global namespace `dde`
|
||||||
(()=> {
|
(()=> {
|
||||||
// src/signals-common.js
|
// src/signals-common.js
|
||||||
var x = {
|
var b = {
|
||||||
isTextContent(e) {
|
isTextContent(e) {
|
||||||
return typeof e == "string";
|
return typeof e == "string";
|
||||||
},
|
},
|
||||||
processReactiveAttribute(e, t, r, n) {
|
processReactiveAttribute(e, t, n, r) {
|
||||||
return r;
|
return n;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function _(e, t = !0) {
|
function _(e, t = !0) {
|
||||||
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e);
|
return t ? Object.assign(b, e) : (Object.setPrototypeOf(e, b), e);
|
||||||
}
|
}
|
||||||
function N(e) {
|
function N(e) {
|
||||||
return x.isPrototypeOf(e) && e !== x ? e : x;
|
return b.isPrototypeOf(e) && e !== b ? e : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/helpers.js
|
// src/helpers.js
|
||||||
@ -24,7 +24,7 @@
|
|||||||
let t = typeof e;
|
let t = typeof e;
|
||||||
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
|
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
|
||||||
}
|
}
|
||||||
function j(e, t) {
|
function D(e, t) {
|
||||||
if (!e || !(e instanceof AbortSignal))
|
if (!e || !(e instanceof AbortSignal))
|
||||||
return !0;
|
return !0;
|
||||||
if (!e.aborted)
|
if (!e.aborted)
|
||||||
@ -34,25 +34,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/dom-common.js
|
// src/dom-common.js
|
||||||
var b = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), T = { setDelete: $ };
|
var x = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), j = { setDeleteAttr: k };
|
||||||
function $(e, t, r) {
|
function k(e, t, n) {
|
||||||
Reflect.set(e, t, r), m(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
|
Reflect.set(e, t, n), m(n) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/dom.js
|
// src/dom.js
|
||||||
var S = "html";
|
var S = "html";
|
||||||
function oe(e) {
|
function ce(e) {
|
||||||
return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
||||||
append(...t) {
|
append(...t) {
|
||||||
return S = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
|
return S = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ce(e, t, ...r) {
|
function ie(e, t, ...n) {
|
||||||
let n = N(this), o;
|
let r = N(this), o;
|
||||||
switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
|
switch (r.isTextContent(t) && (t = { textContent: t }), !0) {
|
||||||
case typeof e == "function": {
|
case typeof e == "function": {
|
||||||
o = e(t || void 0, (i) => i ? (r.unshift(i), void 0) : o);
|
o = e(t || void 0, (i) => i ? (n.unshift(i), void 0) : o);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case e === "#text":
|
case e === "#text":
|
||||||
@ -67,31 +67,31 @@
|
|||||||
case !o:
|
case !o:
|
||||||
o = y(document.createElement(e), t);
|
o = y(document.createElement(e), t);
|
||||||
}
|
}
|
||||||
return r.forEach((a) => a(o)), o;
|
return n.forEach((a) => a(o)), o;
|
||||||
}
|
}
|
||||||
var { setDelete: D } = T;
|
var { setDeleteAttr: q } = j;
|
||||||
function y(e, ...t) {
|
function y(e, ...t) {
|
||||||
let r = N(this);
|
let n = N(this);
|
||||||
if (!t.length)
|
if (!t.length)
|
||||||
return e;
|
return e;
|
||||||
let n = e instanceof SVGElement, o = (n ? W : M).bind(null, e, "Attribute");
|
let r = e instanceof SVGElement, o = (r ? I : T).bind(null, e, "Attribute");
|
||||||
return Object.entries(Object.assign({}, ...t)).forEach(function a([i, s]) {
|
return Object.entries(Object.assign({}, ...t)).forEach(function a([i, s]) {
|
||||||
s = r.processReactiveAttribute(e, i, s, a);
|
s = n.processReactiveAttribute(e, i, s, a);
|
||||||
let [h] = i;
|
let [h] = i;
|
||||||
if (h === "=")
|
if (h === "=")
|
||||||
return o(i.slice(1), s);
|
return o(i.slice(1), s);
|
||||||
if (h === ".")
|
if (h === ".")
|
||||||
return D(e, i.slice(1), s);
|
return M(e, i.slice(1), s);
|
||||||
if (typeof s == "object")
|
if (typeof s == "object")
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case "style":
|
case "style":
|
||||||
return O(s, M.bind(null, e.style, "Property"));
|
return O(s, T.bind(null, e.style, "Property"));
|
||||||
case "dataset":
|
case "dataset":
|
||||||
return O(s, D.bind(null, e.dataset));
|
return O(s, M.bind(null, e.dataset));
|
||||||
case "ariaset":
|
case "ariaset":
|
||||||
return O(s, (E, v) => o("aria-" + E, v));
|
return O(s, (E, v) => o("aria-" + E, v));
|
||||||
case "classList":
|
case "classList":
|
||||||
return q(e, s);
|
return J(e, s);
|
||||||
default:
|
default:
|
||||||
return Reflect.set(e, i, s);
|
return Reflect.set(e, i, s);
|
||||||
}
|
}
|
||||||
@ -103,71 +103,75 @@
|
|||||||
case "xlink:href":
|
case "xlink:href":
|
||||||
return o(i, s, "http://www.w3.org/1999/xlink");
|
return o(i, s, "http://www.w3.org/1999/xlink");
|
||||||
case "textContent":
|
case "textContent":
|
||||||
if (!n)
|
if (!r)
|
||||||
break;
|
break;
|
||||||
return e.appendChild(document.createTextNode(s));
|
return e.appendChild(document.createTextNode(s));
|
||||||
}
|
}
|
||||||
return J(e, i) ? D(e, i, s) : o(i, s);
|
return W(e, i) ? q(e, i, s) : o(i, s);
|
||||||
}), e;
|
}), e;
|
||||||
}
|
}
|
||||||
function q(e, t) {
|
function J(e, t) {
|
||||||
return typeof t != "object" || O(
|
return typeof t != "object" || O(
|
||||||
t,
|
t,
|
||||||
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
|
(n, r) => e.classList.toggle(n, r === -1 ? void 0 : !!r)
|
||||||
), e;
|
), e;
|
||||||
}
|
}
|
||||||
function se(e) {
|
function fe(e) {
|
||||||
return Array.from(e.children).forEach((t) => t.remove()), e;
|
return Array.from(e.children).forEach((t) => t.remove()), e;
|
||||||
}
|
}
|
||||||
function J(e, t) {
|
function W(e, t) {
|
||||||
let r = "HTMLElement," + t;
|
let n = "HTMLElement," + t;
|
||||||
if (e instanceof HTMLElement && b.has(r))
|
if (e instanceof HTMLElement && x.has(n))
|
||||||
return b.get(r);
|
return x.get(n);
|
||||||
let n = e.nodeName + "," + t;
|
let r = e.nodeName + "," + t;
|
||||||
if (b.has(n))
|
if (x.has(r))
|
||||||
return b.get(n);
|
return x.get(r);
|
||||||
let [o, a, i] = H(e, t), s = !m(o.set);
|
let [o, a, i] = H(e, t), s = !m(o.set);
|
||||||
return (!s || a) && b.set(i === HTMLElement.prototype ? r : n, s), s;
|
return (!s || a) && x.set(i === HTMLElement.prototype ? n : r, s), s;
|
||||||
}
|
}
|
||||||
function H(e, t, r = 0) {
|
function H(e, t, n = 0) {
|
||||||
if (e = Object.getPrototypeOf(e), !e)
|
if (e = Object.getPrototypeOf(e), !e)
|
||||||
return [{}, r, e];
|
return [{}, n, e];
|
||||||
let n = Object.getOwnPropertyDescriptor(e, t);
|
let r = Object.getOwnPropertyDescriptor(e, t);
|
||||||
return n ? [n, r, e] : H(e, t, r + 1);
|
return r ? [r, n, e] : H(e, t, n + 1);
|
||||||
}
|
}
|
||||||
function O(e, t) {
|
function O(e, t) {
|
||||||
return Object.entries(e).forEach(([r, n]) => t(r, n));
|
return Object.entries(e).forEach(([n, r]) => n && t(n, r));
|
||||||
}
|
}
|
||||||
function M(e, t, r, n) {
|
function T(e, t, n, r) {
|
||||||
return e[(m(n) ? "remove" : "set") + t](r, n);
|
return e[(m(r) ? "remove" : "set") + t](n, r);
|
||||||
}
|
}
|
||||||
function W(e, t, r, n, o = null) {
|
function I(e, t, n, r, o = null) {
|
||||||
return e[(m(n) ? "remove" : "set") + t + "NS"](o, r, n);
|
return e[(m(r) ? "remove" : "set") + t + "NS"](o, n, r);
|
||||||
|
}
|
||||||
|
function M(e, t, n) {
|
||||||
|
if (Reflect.set(e, t, n), !!m(n))
|
||||||
|
return Reflect.deleteProperty(e, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/events.js
|
// src/events.js
|
||||||
function ae(e, t, ...r) {
|
function de(e, t, ...n) {
|
||||||
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
|
let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
|
||||||
return e.dispatchEvent(n);
|
return e.dispatchEvent(r);
|
||||||
}
|
}
|
||||||
function k(e, t, r) {
|
function F(e, t, n) {
|
||||||
return function(o) {
|
return function(o) {
|
||||||
return o.addEventListener(e, t, r), o;
|
return o.addEventListener(e, t, n), o;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var C = I();
|
var C = Z();
|
||||||
k.connected = function(e, t) {
|
F.connected = function(e, t) {
|
||||||
return function(n) {
|
return function(r) {
|
||||||
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (j(t && t.signal, () => C.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : C.onConnected(n, e)), n);
|
return typeof r.connectedCallback == "function" ? (r.addEventListener("dde:connected", e, t), r) : (D(t && t.signal, () => C.offConnected(r, e)) && (r.isConnected ? e(new Event("dde:connected")) : C.onConnected(r, e)), r);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
k.disconnected = function(e, t) {
|
F.disconnected = function(e, t) {
|
||||||
return function(n) {
|
return function(r) {
|
||||||
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (j(t && t.signal, () => C.offDisconnected(n, e)) && C.onDisconnected(n, e), n);
|
return typeof r.disconnectedCallback == "function" ? (r.addEventListener("dde:disconnected", e, t), r) : (D(t && t.signal, () => C.offDisconnected(r, e)) && C.onDisconnected(r, e), r);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
function I() {
|
function Z() {
|
||||||
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(c) {
|
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(c) {
|
||||||
for (let f of c)
|
for (let f of c)
|
||||||
if (f.type === "childList") {
|
if (f.type === "childList") {
|
||||||
if (E(f.addedNodes, !0)) {
|
if (E(f.addedNodes, !0)) {
|
||||||
@ -185,7 +189,7 @@
|
|||||||
if (!e.has(c))
|
if (!e.has(c))
|
||||||
return;
|
return;
|
||||||
let u = e.get(c), p = u.connected;
|
let u = e.get(c), p = u.connected;
|
||||||
p.splice(p.indexOf(f), 1), n(c, u);
|
p.splice(p.indexOf(f), 1), r(c, u);
|
||||||
},
|
},
|
||||||
onDisconnected(c, f) {
|
onDisconnected(c, f) {
|
||||||
a(), o(c).disconnected.push(f);
|
a(), o(c).disconnected.push(f);
|
||||||
@ -194,10 +198,10 @@
|
|||||||
if (!e.has(c))
|
if (!e.has(c))
|
||||||
return;
|
return;
|
||||||
let u = e.get(c), p = u.disconnected;
|
let u = e.get(c), p = u.disconnected;
|
||||||
p.splice(p.indexOf(f), 1), n(c, u);
|
p.splice(p.indexOf(f), 1), r(c, u);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function n(c, f) {
|
function r(c, f) {
|
||||||
f.connected.length || f.disconnected.length || (e.delete(c), i());
|
f.connected.length || f.disconnected.length || (e.delete(c), i());
|
||||||
}
|
}
|
||||||
function o(c) {
|
function o(c) {
|
||||||
@ -207,10 +211,10 @@
|
|||||||
return e.set(c, f), f;
|
return e.set(c, f), f;
|
||||||
}
|
}
|
||||||
function a() {
|
function a() {
|
||||||
t || (t = !0, r.observe(document.body, { childList: !0, subtree: !0 }));
|
t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
|
||||||
}
|
}
|
||||||
function i() {
|
function i() {
|
||||||
!t || e.size || (t = !1, r.disconnect());
|
!t || e.size || (t = !1, n.disconnect());
|
||||||
}
|
}
|
||||||
function s() {
|
function s() {
|
||||||
return new Promise(function(c) {
|
return new Promise(function(c) {
|
||||||
@ -231,7 +235,7 @@
|
|||||||
if (f && h(u).then(E), !e.has(u))
|
if (f && h(u).then(E), !e.has(u))
|
||||||
continue;
|
continue;
|
||||||
let p = e.get(u);
|
let p = e.get(u);
|
||||||
return p.connected.forEach((A) => A(u)), p.connected.length = 0, p.disconnected.length || e.delete(u), !0;
|
return p.connected.forEach((L) => L(u)), p.connected.length = 0, p.disconnected.length || e.delete(u), !0;
|
||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
@ -240,7 +244,7 @@
|
|||||||
if (f && h(u).then(v), !e.has(u))
|
if (f && h(u).then(v), !e.has(u))
|
||||||
continue;
|
continue;
|
||||||
let p = e.get(u);
|
let p = e.get(u);
|
||||||
return p.disconnected.forEach((A) => A(u)), p.connected.length = 0, p.disconnected.length = 0, e.delete(u), !0;
|
return p.disconnected.forEach((L) => L(u)), p.connected.length = 0, p.disconnected.length = 0, e.delete(u), !0;
|
||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
@ -249,14 +253,14 @@
|
|||||||
// index.js
|
// index.js
|
||||||
[HTMLElement, DocumentFragment].forEach((e) => {
|
[HTMLElement, DocumentFragment].forEach((e) => {
|
||||||
let { append: t } = e.prototype;
|
let { append: t } = e.prototype;
|
||||||
e.prototype.append = function(...r) {
|
e.prototype.append = function(...n) {
|
||||||
return t.apply(this, r), this;
|
return t.apply(this, n), this;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// src/signals-lib.js
|
// src/signals-lib.js
|
||||||
var d = Symbol.for("Signal");
|
var d = Symbol.for("Signal");
|
||||||
function L(e) {
|
function R(e) {
|
||||||
try {
|
try {
|
||||||
return Reflect.has(e, d);
|
return Reflect.has(e, d);
|
||||||
} catch {
|
} catch {
|
||||||
@ -266,26 +270,26 @@
|
|||||||
var l = /* @__PURE__ */ new WeakMap();
|
var l = /* @__PURE__ */ new WeakMap();
|
||||||
function g(e, t) {
|
function g(e, t) {
|
||||||
if (typeof e != "function")
|
if (typeof e != "function")
|
||||||
return F(e, t);
|
return z(e, t);
|
||||||
if (L(e))
|
if (R(e))
|
||||||
return e;
|
return e;
|
||||||
let r = F(""), n = () => r(e());
|
let n = z(""), r = () => n(e());
|
||||||
return l.set(n, /* @__PURE__ */ new Set([r])), G(n), r;
|
return l.set(r, /* @__PURE__ */ new Set([n])), V(r), n;
|
||||||
}
|
}
|
||||||
g.action = function(e, t, ...r) {
|
g.action = function(e, t, ...n) {
|
||||||
let n = e[d], { actions: o } = n;
|
let r = e[d], { actions: o } = r;
|
||||||
if (!o || !Reflect.has(o, t))
|
if (!o || !Reflect.has(o, t))
|
||||||
throw new Error(`'${e}' has no action with name '${t}'!`);
|
throw new Error(`'${e}' has no action with name '${t}'!`);
|
||||||
if (o[t].apply(n, r), n.skip)
|
if (o[t].apply(r, n), r.skip)
|
||||||
return Reflect.deleteProperty(n, "skip");
|
return Reflect.deleteProperty(r, "skip");
|
||||||
n.listeners.forEach((a) => a(n.value));
|
r.listeners.forEach((a) => a(r.value));
|
||||||
};
|
};
|
||||||
g.on = function e(t, r, n = {}) {
|
g.on = function e(t, n, r = {}) {
|
||||||
let { signal: o } = n;
|
let { signal: o } = r;
|
||||||
if (!(o && o.aborted)) {
|
if (!(o && o.aborted)) {
|
||||||
if (Array.isArray(t))
|
if (Array.isArray(t))
|
||||||
return t.forEach((a) => e(a, r, n));
|
return t.forEach((a) => e(a, n, r));
|
||||||
P(t, r), o && o.addEventListener("abort", () => U(t, r));
|
P(t, n), o && o.addEventListener("abort", () => $(t, n));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
g.symbols = {
|
g.symbols = {
|
||||||
@ -293,108 +297,108 @@
|
|||||||
onclear: Symbol.for("Signal.onclear")
|
onclear: Symbol.for("Signal.onclear")
|
||||||
};
|
};
|
||||||
g.clear = function(...e) {
|
g.clear = function(...e) {
|
||||||
for (let r of e) {
|
for (let n of e) {
|
||||||
Reflect.deleteProperty(r, "toJSON");
|
Reflect.deleteProperty(n, "toJSON");
|
||||||
let n = r[d], { onclear: o } = g.symbols;
|
let r = n[d], { onclear: o } = g.symbols;
|
||||||
n.actions && n.actions[o] && n.actions[o].call(n), t(r, n), Reflect.deleteProperty(r, d);
|
r.actions && r.actions[o] && r.actions[o].call(r), t(n, r), Reflect.deleteProperty(n, d);
|
||||||
}
|
}
|
||||||
function t(r, n) {
|
function t(n, r) {
|
||||||
n.listeners.forEach((o) => {
|
r.listeners.forEach((o) => {
|
||||||
if (n.listeners.delete(o), !l.has(o))
|
if (r.listeners.delete(o), !l.has(o))
|
||||||
return;
|
return;
|
||||||
let a = l.get(o);
|
let a = l.get(o);
|
||||||
a.delete(r), !(a.size > 1) && (g.clear(...a), l.delete(o));
|
a.delete(n), !(a.size > 1) && (g.clear(...a), l.delete(o));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
g.el = function(e, t) {
|
g.el = function(e, t) {
|
||||||
let r = document.createComment("<#reactive>"), n = document.createComment("</#reactive>"), o = document.createDocumentFragment();
|
let n = document.createComment("<#reactive>"), r = document.createComment("</#reactive>"), o = document.createDocumentFragment();
|
||||||
o.append(r, n);
|
o.append(n, r);
|
||||||
let a = (i) => {
|
let a = (i) => {
|
||||||
if (!r.parentNode || !n.parentNode)
|
if (!n.parentNode || !r.parentNode)
|
||||||
return U(e, a);
|
return $(e, a);
|
||||||
let s = t(i);
|
let s = t(i);
|
||||||
Array.isArray(s) || (s = [s]);
|
Array.isArray(s) || (s = [s]);
|
||||||
let h = r;
|
let h = n;
|
||||||
for (; (h = r.nextSibling) !== n; )
|
for (; (h = n.nextSibling) !== r; )
|
||||||
h.remove();
|
h.remove();
|
||||||
r.after(...s);
|
n.after(...s);
|
||||||
};
|
};
|
||||||
return P(e, a), a(e()), o;
|
return P(e, a), a(e()), o;
|
||||||
};
|
};
|
||||||
var z = {
|
var U = {
|
||||||
isTextContent(e) {
|
isTextContent(e) {
|
||||||
return w(e) === "string" || L(e) && w(X(e)) === "string";
|
return w(e) === "string" || R(e) && w(Y(e)) === "string";
|
||||||
},
|
},
|
||||||
processReactiveAttribute(e, t, r, n) {
|
processReactiveAttribute(e, t, n, r) {
|
||||||
return L(r) ? (P(r, (o) => n([t, o])), r()) : r;
|
return R(n) ? (P(n, (o) => r([t, o])), n()) : n;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function F(e, t) {
|
function z(e, t) {
|
||||||
let r = (...n) => n.length ? Q(r, n[0]) : K(r);
|
let n = (...r) => r.length ? X(n, r[0]) : Q(n);
|
||||||
return B(r, e, t);
|
return G(n, e, t);
|
||||||
}
|
}
|
||||||
var Z = Object.assign(/* @__PURE__ */ Object.create(null), {
|
var B = Object.assign(/* @__PURE__ */ Object.create(null), {
|
||||||
stopPropagation() {
|
stopPropagation() {
|
||||||
this.skip = !0;
|
this.skip = !0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function B(e, t, r) {
|
function G(e, t, n) {
|
||||||
return w(r) !== "[object Object]" && (r = {}), e[d] = {
|
return w(n) !== "[object Object]" && (n = {}), e[d] = {
|
||||||
value: t,
|
value: t,
|
||||||
actions: r,
|
actions: n,
|
||||||
listeners: /* @__PURE__ */ new Set()
|
listeners: /* @__PURE__ */ new Set()
|
||||||
}, e.toJSON = () => e(), Object.setPrototypeOf(e[d], Z), e;
|
}, e.toJSON = () => e(), Object.setPrototypeOf(e[d], B), e;
|
||||||
}
|
}
|
||||||
var R = [];
|
var A = [];
|
||||||
function G(e) {
|
function V(e) {
|
||||||
let t = function() {
|
let t = function() {
|
||||||
R.push(t), e(), R.pop();
|
A.push(t), e(), A.pop();
|
||||||
};
|
};
|
||||||
l.has(e) && (l.set(t, l.get(e)), l.delete(e)), t();
|
l.has(e) && (l.set(t, l.get(e)), l.delete(e)), t();
|
||||||
}
|
}
|
||||||
function V() {
|
function K() {
|
||||||
return R[R.length - 1];
|
return A[A.length - 1];
|
||||||
}
|
}
|
||||||
function K(e) {
|
function Q(e) {
|
||||||
if (!e[d])
|
if (!e[d])
|
||||||
return;
|
return;
|
||||||
let { value: t, listeners: r } = e[d], n = V();
|
let { value: t, listeners: n } = e[d], r = K();
|
||||||
return n && r.add(n), l.has(n) && l.get(n).add(e), t;
|
return r && n.add(r), l.has(r) && l.get(r).add(e), t;
|
||||||
}
|
}
|
||||||
function Q(e, t) {
|
function X(e, t) {
|
||||||
if (!e[d])
|
if (!e[d])
|
||||||
return;
|
return;
|
||||||
let r = e[d];
|
let n = e[d];
|
||||||
if (r.value !== t)
|
if (n.value !== t)
|
||||||
return r.value = t, r.listeners.forEach((n) => n(t)), t;
|
return n.value = t, n.listeners.forEach((r) => r(t)), t;
|
||||||
}
|
}
|
||||||
function X(e) {
|
function Y(e) {
|
||||||
return e[d].value;
|
return e[d].value;
|
||||||
}
|
}
|
||||||
function P(e, t) {
|
function P(e, t) {
|
||||||
if (e[d])
|
if (e[d])
|
||||||
return e[d].listeners.add(t);
|
return e[d].listeners.add(t);
|
||||||
}
|
}
|
||||||
function U(e, t) {
|
function $(e, t) {
|
||||||
if (e[d])
|
if (e[d])
|
||||||
return e[d].listeners.delete(t);
|
return e[d].listeners.delete(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// signals.js
|
// signals.js
|
||||||
_(z);
|
_(U);
|
||||||
|
|
||||||
globalThis.dde= {
|
globalThis.dde= {
|
||||||
S: g,
|
S: g,
|
||||||
assign: y,
|
assign: y,
|
||||||
classListDeclarative: q,
|
classListDeclarative: J,
|
||||||
createElement: ce,
|
createElement: ie,
|
||||||
dispatchEvent: ae,
|
dispatchEvent: de,
|
||||||
el: ce,
|
el: ie,
|
||||||
empty: se,
|
empty: fe,
|
||||||
isSignal: L,
|
isSignal: R,
|
||||||
namespace: oe,
|
namespace: ce,
|
||||||
on: k,
|
on: F,
|
||||||
registerReactivity: _
|
registerReactivity: _
|
||||||
};
|
};
|
||||||
|
|
||||||
|
100
dist/dde.js
vendored
100
dist/dde.js
vendored
@ -9,7 +9,7 @@
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function T(e, t = !0) {
|
function _(e, t = !0) {
|
||||||
return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e);
|
return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e);
|
||||||
}
|
}
|
||||||
function O(e) {
|
function O(e) {
|
||||||
@ -30,21 +30,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/dom-common.js
|
// src/dom-common.js
|
||||||
var h = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), A = { setDelete: R };
|
var l = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), A = { setDeleteAttr: T };
|
||||||
function R(e, t, r) {
|
function T(e, t, r) {
|
||||||
Reflect.set(e, t, r), p(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
|
Reflect.set(e, t, r), p(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/dom.js
|
// src/dom.js
|
||||||
var v = "html";
|
var v = "html";
|
||||||
function I(e) {
|
function Z(e) {
|
||||||
return v = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
return v = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
||||||
append(...t) {
|
append(...t) {
|
||||||
return v = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
|
return v = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function Z(e, t, ...r) {
|
function $(e, t, ...r) {
|
||||||
let n = O(this), c;
|
let n = O(this), c;
|
||||||
switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
|
switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
|
||||||
case typeof e == "function": {
|
case typeof e == "function": {
|
||||||
@ -52,31 +52,31 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case e === "#text":
|
case e === "#text":
|
||||||
c = E(document.createTextNode(""), t);
|
c = b(document.createTextNode(""), t);
|
||||||
break;
|
break;
|
||||||
case e === "<>":
|
case e === "<>":
|
||||||
c = E(document.createDocumentFragment(), t);
|
c = b(document.createDocumentFragment(), t);
|
||||||
break;
|
break;
|
||||||
case v !== "html":
|
case v !== "html":
|
||||||
c = E(document.createElementNS(v, e), t);
|
c = b(document.createElementNS(v, e), t);
|
||||||
break;
|
break;
|
||||||
case !c:
|
case !c:
|
||||||
c = E(document.createElement(e), t);
|
c = b(document.createElement(e), t);
|
||||||
}
|
}
|
||||||
return r.forEach((a) => a(c)), c;
|
return r.forEach((a) => a(c)), c;
|
||||||
}
|
}
|
||||||
var { setDelete: y } = A;
|
var { setDeleteAttr: M } = A;
|
||||||
function E(e, ...t) {
|
function b(e, ...t) {
|
||||||
let r = O(this);
|
let r = O(this);
|
||||||
if (!t.length)
|
if (!t.length)
|
||||||
return e;
|
return e;
|
||||||
let n = e instanceof SVGElement, c = (n ? S : N).bind(null, e, "Attribute");
|
let n = e instanceof SVGElement, c = (n ? j : N).bind(null, e, "Attribute");
|
||||||
return Object.entries(Object.assign({}, ...t)).forEach(function a([s, f]) {
|
return Object.entries(Object.assign({}, ...t)).forEach(function a([s, f]) {
|
||||||
f = r.processReactiveAttribute(e, s, f, a);
|
f = r.processReactiveAttribute(e, s, f, a);
|
||||||
let [l] = s;
|
let [h] = s;
|
||||||
if (l === "=")
|
if (h === "=")
|
||||||
return c(s.slice(1), f);
|
return c(s.slice(1), f);
|
||||||
if (l === ".")
|
if (h === ".")
|
||||||
return y(e, s.slice(1), f);
|
return y(e, s.slice(1), f);
|
||||||
if (typeof f == "object")
|
if (typeof f == "object")
|
||||||
switch (s) {
|
switch (s) {
|
||||||
@ -85,9 +85,9 @@
|
|||||||
case "dataset":
|
case "dataset":
|
||||||
return m(f, y.bind(null, e.dataset));
|
return m(f, y.bind(null, e.dataset));
|
||||||
case "ariaset":
|
case "ariaset":
|
||||||
return m(f, (x, b) => c("aria-" + x, b));
|
return m(f, (x, E) => c("aria-" + x, E));
|
||||||
case "classList":
|
case "classList":
|
||||||
return j(e, f);
|
return P(e, f);
|
||||||
default:
|
default:
|
||||||
return Reflect.set(e, s, f);
|
return Reflect.set(e, s, f);
|
||||||
}
|
}
|
||||||
@ -103,27 +103,27 @@
|
|||||||
break;
|
break;
|
||||||
return e.appendChild(document.createTextNode(f));
|
return e.appendChild(document.createTextNode(f));
|
||||||
}
|
}
|
||||||
return M(e, s) ? y(e, s, f) : c(s, f);
|
return S(e, s) ? M(e, s, f) : c(s, f);
|
||||||
}), e;
|
}), e;
|
||||||
}
|
}
|
||||||
function j(e, t) {
|
function P(e, t) {
|
||||||
return typeof t != "object" || m(
|
return typeof t != "object" || m(
|
||||||
t,
|
t,
|
||||||
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
|
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
|
||||||
), e;
|
), e;
|
||||||
}
|
}
|
||||||
function B(e) {
|
function G(e) {
|
||||||
return Array.from(e.children).forEach((t) => t.remove()), e;
|
return Array.from(e.children).forEach((t) => t.remove()), e;
|
||||||
}
|
}
|
||||||
function M(e, t) {
|
function S(e, t) {
|
||||||
let r = "HTMLElement," + t;
|
let r = "HTMLElement," + t;
|
||||||
if (e instanceof HTMLElement && h.has(r))
|
if (e instanceof HTMLElement && l.has(r))
|
||||||
return h.get(r);
|
return l.get(r);
|
||||||
let n = e.nodeName + "," + t;
|
let n = e.nodeName + "," + t;
|
||||||
if (h.has(n))
|
if (l.has(n))
|
||||||
return h.get(n);
|
return l.get(n);
|
||||||
let [c, a, s] = D(e, t), f = !p(c.set);
|
let [c, a, s] = D(e, t), f = !p(c.set);
|
||||||
return (!f || a) && h.set(s === HTMLElement.prototype ? r : n, f), f;
|
return (!f || a) && l.set(s === HTMLElement.prototype ? r : n, f), f;
|
||||||
}
|
}
|
||||||
function D(e, t, r = 0) {
|
function D(e, t, r = 0) {
|
||||||
if (e = Object.getPrototypeOf(e), !e)
|
if (e = Object.getPrototypeOf(e), !e)
|
||||||
@ -132,37 +132,41 @@
|
|||||||
return n ? [n, r, e] : D(e, t, r + 1);
|
return n ? [n, r, e] : D(e, t, r + 1);
|
||||||
}
|
}
|
||||||
function m(e, t) {
|
function m(e, t) {
|
||||||
return Object.entries(e).forEach(([r, n]) => t(r, n));
|
return Object.entries(e).forEach(([r, n]) => r && t(r, n));
|
||||||
}
|
}
|
||||||
function N(e, t, r, n) {
|
function N(e, t, r, n) {
|
||||||
return e[(p(n) ? "remove" : "set") + t](r, n);
|
return e[(p(n) ? "remove" : "set") + t](r, n);
|
||||||
}
|
}
|
||||||
function S(e, t, r, n, c = null) {
|
function j(e, t, r, n, c = null) {
|
||||||
return e[(p(n) ? "remove" : "set") + t + "NS"](c, r, n);
|
return e[(p(n) ? "remove" : "set") + t + "NS"](c, r, n);
|
||||||
}
|
}
|
||||||
|
function y(e, t, r) {
|
||||||
|
if (Reflect.set(e, t, r), !!p(r))
|
||||||
|
return Reflect.deleteProperty(e, t);
|
||||||
|
}
|
||||||
|
|
||||||
// src/events.js
|
// src/events.js
|
||||||
function V(e, t, ...r) {
|
function W(e, t, ...r) {
|
||||||
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
|
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
|
||||||
return e.dispatchEvent(n);
|
return e.dispatchEvent(n);
|
||||||
}
|
}
|
||||||
function _(e, t, r) {
|
function R(e, t, r) {
|
||||||
return function(c) {
|
return function(c) {
|
||||||
return c.addEventListener(e, t, r), c;
|
return c.addEventListener(e, t, r), c;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var w = P();
|
var w = H();
|
||||||
_.connected = function(e, t) {
|
R.connected = function(e, t) {
|
||||||
return function(n) {
|
return function(n) {
|
||||||
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (L(t && t.signal, () => w.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : w.onConnected(n, e)), n);
|
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (L(t && t.signal, () => w.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : w.onConnected(n, e)), n);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
_.disconnected = function(e, t) {
|
R.disconnected = function(e, t) {
|
||||||
return function(n) {
|
return function(n) {
|
||||||
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (L(t && t.signal, () => w.offDisconnected(n, e)) && w.onDisconnected(n, e), n);
|
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (L(t && t.signal, () => w.offDisconnected(n, e)) && w.onDisconnected(n, e), n);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
function P() {
|
function H() {
|
||||||
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) {
|
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) {
|
||||||
for (let i of o)
|
for (let i of o)
|
||||||
if (i.type === "childList") {
|
if (i.type === "childList") {
|
||||||
@ -170,7 +174,7 @@
|
|||||||
s();
|
s();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
b(i.removedNodes, !0) && s();
|
E(i.removedNodes, !0) && s();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
@ -213,7 +217,7 @@
|
|||||||
(requestIdleCallback || requestAnimationFrame)(o);
|
(requestIdleCallback || requestAnimationFrame)(o);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async function l(o) {
|
async function h(o) {
|
||||||
e.size > 30 && await f();
|
e.size > 30 && await f();
|
||||||
let i = [];
|
let i = [];
|
||||||
if (!(o instanceof Node))
|
if (!(o instanceof Node))
|
||||||
@ -224,16 +228,16 @@
|
|||||||
}
|
}
|
||||||
function x(o, i) {
|
function x(o, i) {
|
||||||
for (let u of o) {
|
for (let u of o) {
|
||||||
if (i && l(u).then(x), !e.has(u))
|
if (i && h(u).then(x), !e.has(u))
|
||||||
continue;
|
continue;
|
||||||
let d = e.get(u);
|
let d = e.get(u);
|
||||||
return d.connected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length || e.delete(u), !0;
|
return d.connected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length || e.delete(u), !0;
|
||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
function b(o, i) {
|
function E(o, i) {
|
||||||
for (let u of o) {
|
for (let u of o) {
|
||||||
if (i && l(u).then(b), !e.has(u))
|
if (i && h(u).then(E), !e.has(u))
|
||||||
continue;
|
continue;
|
||||||
let d = e.get(u);
|
let d = e.get(u);
|
||||||
return d.disconnected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length = 0, e.delete(u), !0;
|
return d.disconnected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length = 0, e.delete(u), !0;
|
||||||
@ -251,15 +255,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
globalThis.dde= {
|
globalThis.dde= {
|
||||||
assign: E,
|
assign: b,
|
||||||
classListDeclarative: j,
|
classListDeclarative: P,
|
||||||
createElement: Z,
|
createElement: $,
|
||||||
dispatchEvent: V,
|
dispatchEvent: W,
|
||||||
el: Z,
|
el: $,
|
||||||
empty: B,
|
empty: G,
|
||||||
namespace: I,
|
namespace: Z,
|
||||||
on: _,
|
on: R,
|
||||||
registerReactivity: T
|
registerReactivity: _
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
268
dist/esm-with-signals.js
vendored
268
dist/esm-with-signals.js
vendored
@ -1,17 +1,17 @@
|
|||||||
// src/signals-common.js
|
// src/signals-common.js
|
||||||
var x = {
|
var b = {
|
||||||
isTextContent(e) {
|
isTextContent(e) {
|
||||||
return typeof e == "string";
|
return typeof e == "string";
|
||||||
},
|
},
|
||||||
processReactiveAttribute(e, t, r, n) {
|
processReactiveAttribute(e, t, n, r) {
|
||||||
return r;
|
return n;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function _(e, t = !0) {
|
function _(e, t = !0) {
|
||||||
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e);
|
return t ? Object.assign(b, e) : (Object.setPrototypeOf(e, b), e);
|
||||||
}
|
}
|
||||||
function N(e) {
|
function N(e) {
|
||||||
return x.isPrototypeOf(e) && e !== x ? e : x;
|
return b.isPrototypeOf(e) && e !== b ? e : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/helpers.js
|
// src/helpers.js
|
||||||
@ -22,7 +22,7 @@ function w(e) {
|
|||||||
let t = typeof e;
|
let t = typeof e;
|
||||||
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
|
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
|
||||||
}
|
}
|
||||||
function j(e, t) {
|
function D(e, t) {
|
||||||
if (!e || !(e instanceof AbortSignal))
|
if (!e || !(e instanceof AbortSignal))
|
||||||
return !0;
|
return !0;
|
||||||
if (!e.aborted)
|
if (!e.aborted)
|
||||||
@ -32,25 +32,25 @@ function j(e, t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/dom-common.js
|
// src/dom-common.js
|
||||||
var b = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), T = { setDelete: $ };
|
var x = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), j = { setDeleteAttr: k };
|
||||||
function $(e, t, r) {
|
function k(e, t, n) {
|
||||||
Reflect.set(e, t, r), m(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
|
Reflect.set(e, t, n), m(n) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/dom.js
|
// src/dom.js
|
||||||
var S = "html";
|
var S = "html";
|
||||||
function oe(e) {
|
function ce(e) {
|
||||||
return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
||||||
append(...t) {
|
append(...t) {
|
||||||
return S = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
|
return S = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ce(e, t, ...r) {
|
function ie(e, t, ...n) {
|
||||||
let n = N(this), o;
|
let r = N(this), o;
|
||||||
switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
|
switch (r.isTextContent(t) && (t = { textContent: t }), !0) {
|
||||||
case typeof e == "function": {
|
case typeof e == "function": {
|
||||||
o = e(t || void 0, (i) => i ? (r.unshift(i), void 0) : o);
|
o = e(t || void 0, (i) => i ? (n.unshift(i), void 0) : o);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case e === "#text":
|
case e === "#text":
|
||||||
@ -65,31 +65,31 @@ function ce(e, t, ...r) {
|
|||||||
case !o:
|
case !o:
|
||||||
o = y(document.createElement(e), t);
|
o = y(document.createElement(e), t);
|
||||||
}
|
}
|
||||||
return r.forEach((a) => a(o)), o;
|
return n.forEach((a) => a(o)), o;
|
||||||
}
|
}
|
||||||
var { setDelete: D } = T;
|
var { setDeleteAttr: q } = j;
|
||||||
function y(e, ...t) {
|
function y(e, ...t) {
|
||||||
let r = N(this);
|
let n = N(this);
|
||||||
if (!t.length)
|
if (!t.length)
|
||||||
return e;
|
return e;
|
||||||
let n = e instanceof SVGElement, o = (n ? W : M).bind(null, e, "Attribute");
|
let r = e instanceof SVGElement, o = (r ? I : T).bind(null, e, "Attribute");
|
||||||
return Object.entries(Object.assign({}, ...t)).forEach(function a([i, s]) {
|
return Object.entries(Object.assign({}, ...t)).forEach(function a([i, s]) {
|
||||||
s = r.processReactiveAttribute(e, i, s, a);
|
s = n.processReactiveAttribute(e, i, s, a);
|
||||||
let [h] = i;
|
let [h] = i;
|
||||||
if (h === "=")
|
if (h === "=")
|
||||||
return o(i.slice(1), s);
|
return o(i.slice(1), s);
|
||||||
if (h === ".")
|
if (h === ".")
|
||||||
return D(e, i.slice(1), s);
|
return M(e, i.slice(1), s);
|
||||||
if (typeof s == "object")
|
if (typeof s == "object")
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case "style":
|
case "style":
|
||||||
return O(s, M.bind(null, e.style, "Property"));
|
return O(s, T.bind(null, e.style, "Property"));
|
||||||
case "dataset":
|
case "dataset":
|
||||||
return O(s, D.bind(null, e.dataset));
|
return O(s, M.bind(null, e.dataset));
|
||||||
case "ariaset":
|
case "ariaset":
|
||||||
return O(s, (E, v) => o("aria-" + E, v));
|
return O(s, (E, v) => o("aria-" + E, v));
|
||||||
case "classList":
|
case "classList":
|
||||||
return q(e, s);
|
return J(e, s);
|
||||||
default:
|
default:
|
||||||
return Reflect.set(e, i, s);
|
return Reflect.set(e, i, s);
|
||||||
}
|
}
|
||||||
@ -101,71 +101,75 @@ function y(e, ...t) {
|
|||||||
case "xlink:href":
|
case "xlink:href":
|
||||||
return o(i, s, "http://www.w3.org/1999/xlink");
|
return o(i, s, "http://www.w3.org/1999/xlink");
|
||||||
case "textContent":
|
case "textContent":
|
||||||
if (!n)
|
if (!r)
|
||||||
break;
|
break;
|
||||||
return e.appendChild(document.createTextNode(s));
|
return e.appendChild(document.createTextNode(s));
|
||||||
}
|
}
|
||||||
return J(e, i) ? D(e, i, s) : o(i, s);
|
return W(e, i) ? q(e, i, s) : o(i, s);
|
||||||
}), e;
|
}), e;
|
||||||
}
|
}
|
||||||
function q(e, t) {
|
function J(e, t) {
|
||||||
return typeof t != "object" || O(
|
return typeof t != "object" || O(
|
||||||
t,
|
t,
|
||||||
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
|
(n, r) => e.classList.toggle(n, r === -1 ? void 0 : !!r)
|
||||||
), e;
|
), e;
|
||||||
}
|
}
|
||||||
function se(e) {
|
function fe(e) {
|
||||||
return Array.from(e.children).forEach((t) => t.remove()), e;
|
return Array.from(e.children).forEach((t) => t.remove()), e;
|
||||||
}
|
}
|
||||||
function J(e, t) {
|
function W(e, t) {
|
||||||
let r = "HTMLElement," + t;
|
let n = "HTMLElement," + t;
|
||||||
if (e instanceof HTMLElement && b.has(r))
|
if (e instanceof HTMLElement && x.has(n))
|
||||||
return b.get(r);
|
return x.get(n);
|
||||||
let n = e.nodeName + "," + t;
|
let r = e.nodeName + "," + t;
|
||||||
if (b.has(n))
|
if (x.has(r))
|
||||||
return b.get(n);
|
return x.get(r);
|
||||||
let [o, a, i] = H(e, t), s = !m(o.set);
|
let [o, a, i] = H(e, t), s = !m(o.set);
|
||||||
return (!s || a) && b.set(i === HTMLElement.prototype ? r : n, s), s;
|
return (!s || a) && x.set(i === HTMLElement.prototype ? n : r, s), s;
|
||||||
}
|
}
|
||||||
function H(e, t, r = 0) {
|
function H(e, t, n = 0) {
|
||||||
if (e = Object.getPrototypeOf(e), !e)
|
if (e = Object.getPrototypeOf(e), !e)
|
||||||
return [{}, r, e];
|
return [{}, n, e];
|
||||||
let n = Object.getOwnPropertyDescriptor(e, t);
|
let r = Object.getOwnPropertyDescriptor(e, t);
|
||||||
return n ? [n, r, e] : H(e, t, r + 1);
|
return r ? [r, n, e] : H(e, t, n + 1);
|
||||||
}
|
}
|
||||||
function O(e, t) {
|
function O(e, t) {
|
||||||
return Object.entries(e).forEach(([r, n]) => t(r, n));
|
return Object.entries(e).forEach(([n, r]) => n && t(n, r));
|
||||||
}
|
}
|
||||||
function M(e, t, r, n) {
|
function T(e, t, n, r) {
|
||||||
return e[(m(n) ? "remove" : "set") + t](r, n);
|
return e[(m(r) ? "remove" : "set") + t](n, r);
|
||||||
}
|
}
|
||||||
function W(e, t, r, n, o = null) {
|
function I(e, t, n, r, o = null) {
|
||||||
return e[(m(n) ? "remove" : "set") + t + "NS"](o, r, n);
|
return e[(m(r) ? "remove" : "set") + t + "NS"](o, n, r);
|
||||||
|
}
|
||||||
|
function M(e, t, n) {
|
||||||
|
if (Reflect.set(e, t, n), !!m(n))
|
||||||
|
return Reflect.deleteProperty(e, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/events.js
|
// src/events.js
|
||||||
function ae(e, t, ...r) {
|
function de(e, t, ...n) {
|
||||||
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
|
let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
|
||||||
return e.dispatchEvent(n);
|
return e.dispatchEvent(r);
|
||||||
}
|
}
|
||||||
function k(e, t, r) {
|
function F(e, t, n) {
|
||||||
return function(o) {
|
return function(o) {
|
||||||
return o.addEventListener(e, t, r), o;
|
return o.addEventListener(e, t, n), o;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var C = I();
|
var C = Z();
|
||||||
k.connected = function(e, t) {
|
F.connected = function(e, t) {
|
||||||
return function(n) {
|
return function(r) {
|
||||||
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (j(t && t.signal, () => C.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : C.onConnected(n, e)), n);
|
return typeof r.connectedCallback == "function" ? (r.addEventListener("dde:connected", e, t), r) : (D(t && t.signal, () => C.offConnected(r, e)) && (r.isConnected ? e(new Event("dde:connected")) : C.onConnected(r, e)), r);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
k.disconnected = function(e, t) {
|
F.disconnected = function(e, t) {
|
||||||
return function(n) {
|
return function(r) {
|
||||||
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (j(t && t.signal, () => C.offDisconnected(n, e)) && C.onDisconnected(n, e), n);
|
return typeof r.disconnectedCallback == "function" ? (r.addEventListener("dde:disconnected", e, t), r) : (D(t && t.signal, () => C.offDisconnected(r, e)) && C.onDisconnected(r, e), r);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
function I() {
|
function Z() {
|
||||||
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(c) {
|
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(c) {
|
||||||
for (let f of c)
|
for (let f of c)
|
||||||
if (f.type === "childList") {
|
if (f.type === "childList") {
|
||||||
if (E(f.addedNodes, !0)) {
|
if (E(f.addedNodes, !0)) {
|
||||||
@ -183,7 +187,7 @@ function I() {
|
|||||||
if (!e.has(c))
|
if (!e.has(c))
|
||||||
return;
|
return;
|
||||||
let u = e.get(c), p = u.connected;
|
let u = e.get(c), p = u.connected;
|
||||||
p.splice(p.indexOf(f), 1), n(c, u);
|
p.splice(p.indexOf(f), 1), r(c, u);
|
||||||
},
|
},
|
||||||
onDisconnected(c, f) {
|
onDisconnected(c, f) {
|
||||||
a(), o(c).disconnected.push(f);
|
a(), o(c).disconnected.push(f);
|
||||||
@ -192,10 +196,10 @@ function I() {
|
|||||||
if (!e.has(c))
|
if (!e.has(c))
|
||||||
return;
|
return;
|
||||||
let u = e.get(c), p = u.disconnected;
|
let u = e.get(c), p = u.disconnected;
|
||||||
p.splice(p.indexOf(f), 1), n(c, u);
|
p.splice(p.indexOf(f), 1), r(c, u);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function n(c, f) {
|
function r(c, f) {
|
||||||
f.connected.length || f.disconnected.length || (e.delete(c), i());
|
f.connected.length || f.disconnected.length || (e.delete(c), i());
|
||||||
}
|
}
|
||||||
function o(c) {
|
function o(c) {
|
||||||
@ -205,10 +209,10 @@ function I() {
|
|||||||
return e.set(c, f), f;
|
return e.set(c, f), f;
|
||||||
}
|
}
|
||||||
function a() {
|
function a() {
|
||||||
t || (t = !0, r.observe(document.body, { childList: !0, subtree: !0 }));
|
t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
|
||||||
}
|
}
|
||||||
function i() {
|
function i() {
|
||||||
!t || e.size || (t = !1, r.disconnect());
|
!t || e.size || (t = !1, n.disconnect());
|
||||||
}
|
}
|
||||||
function s() {
|
function s() {
|
||||||
return new Promise(function(c) {
|
return new Promise(function(c) {
|
||||||
@ -229,7 +233,7 @@ function I() {
|
|||||||
if (f && h(u).then(E), !e.has(u))
|
if (f && h(u).then(E), !e.has(u))
|
||||||
continue;
|
continue;
|
||||||
let p = e.get(u);
|
let p = e.get(u);
|
||||||
return p.connected.forEach((A) => A(u)), p.connected.length = 0, p.disconnected.length || e.delete(u), !0;
|
return p.connected.forEach((L) => L(u)), p.connected.length = 0, p.disconnected.length || e.delete(u), !0;
|
||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
@ -238,7 +242,7 @@ function I() {
|
|||||||
if (f && h(u).then(v), !e.has(u))
|
if (f && h(u).then(v), !e.has(u))
|
||||||
continue;
|
continue;
|
||||||
let p = e.get(u);
|
let p = e.get(u);
|
||||||
return p.disconnected.forEach((A) => A(u)), p.connected.length = 0, p.disconnected.length = 0, e.delete(u), !0;
|
return p.disconnected.forEach((L) => L(u)), p.connected.length = 0, p.disconnected.length = 0, e.delete(u), !0;
|
||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
@ -247,14 +251,14 @@ function I() {
|
|||||||
// index.js
|
// index.js
|
||||||
[HTMLElement, DocumentFragment].forEach((e) => {
|
[HTMLElement, DocumentFragment].forEach((e) => {
|
||||||
let { append: t } = e.prototype;
|
let { append: t } = e.prototype;
|
||||||
e.prototype.append = function(...r) {
|
e.prototype.append = function(...n) {
|
||||||
return t.apply(this, r), this;
|
return t.apply(this, n), this;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// src/signals-lib.js
|
// src/signals-lib.js
|
||||||
var d = Symbol.for("Signal");
|
var d = Symbol.for("Signal");
|
||||||
function L(e) {
|
function R(e) {
|
||||||
try {
|
try {
|
||||||
return Reflect.has(e, d);
|
return Reflect.has(e, d);
|
||||||
} catch {
|
} catch {
|
||||||
@ -264,26 +268,26 @@ function L(e) {
|
|||||||
var l = /* @__PURE__ */ new WeakMap();
|
var l = /* @__PURE__ */ new WeakMap();
|
||||||
function g(e, t) {
|
function g(e, t) {
|
||||||
if (typeof e != "function")
|
if (typeof e != "function")
|
||||||
return F(e, t);
|
return z(e, t);
|
||||||
if (L(e))
|
if (R(e))
|
||||||
return e;
|
return e;
|
||||||
let r = F(""), n = () => r(e());
|
let n = z(""), r = () => n(e());
|
||||||
return l.set(n, /* @__PURE__ */ new Set([r])), G(n), r;
|
return l.set(r, /* @__PURE__ */ new Set([n])), V(r), n;
|
||||||
}
|
}
|
||||||
g.action = function(e, t, ...r) {
|
g.action = function(e, t, ...n) {
|
||||||
let n = e[d], { actions: o } = n;
|
let r = e[d], { actions: o } = r;
|
||||||
if (!o || !Reflect.has(o, t))
|
if (!o || !Reflect.has(o, t))
|
||||||
throw new Error(`'${e}' has no action with name '${t}'!`);
|
throw new Error(`'${e}' has no action with name '${t}'!`);
|
||||||
if (o[t].apply(n, r), n.skip)
|
if (o[t].apply(r, n), r.skip)
|
||||||
return Reflect.deleteProperty(n, "skip");
|
return Reflect.deleteProperty(r, "skip");
|
||||||
n.listeners.forEach((a) => a(n.value));
|
r.listeners.forEach((a) => a(r.value));
|
||||||
};
|
};
|
||||||
g.on = function e(t, r, n = {}) {
|
g.on = function e(t, n, r = {}) {
|
||||||
let { signal: o } = n;
|
let { signal: o } = r;
|
||||||
if (!(o && o.aborted)) {
|
if (!(o && o.aborted)) {
|
||||||
if (Array.isArray(t))
|
if (Array.isArray(t))
|
||||||
return t.forEach((a) => e(a, r, n));
|
return t.forEach((a) => e(a, n, r));
|
||||||
P(t, r), o && o.addEventListener("abort", () => U(t, r));
|
P(t, n), o && o.addEventListener("abort", () => $(t, n));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
g.symbols = {
|
g.symbols = {
|
||||||
@ -291,106 +295,106 @@ g.symbols = {
|
|||||||
onclear: Symbol.for("Signal.onclear")
|
onclear: Symbol.for("Signal.onclear")
|
||||||
};
|
};
|
||||||
g.clear = function(...e) {
|
g.clear = function(...e) {
|
||||||
for (let r of e) {
|
for (let n of e) {
|
||||||
Reflect.deleteProperty(r, "toJSON");
|
Reflect.deleteProperty(n, "toJSON");
|
||||||
let n = r[d], { onclear: o } = g.symbols;
|
let r = n[d], { onclear: o } = g.symbols;
|
||||||
n.actions && n.actions[o] && n.actions[o].call(n), t(r, n), Reflect.deleteProperty(r, d);
|
r.actions && r.actions[o] && r.actions[o].call(r), t(n, r), Reflect.deleteProperty(n, d);
|
||||||
}
|
}
|
||||||
function t(r, n) {
|
function t(n, r) {
|
||||||
n.listeners.forEach((o) => {
|
r.listeners.forEach((o) => {
|
||||||
if (n.listeners.delete(o), !l.has(o))
|
if (r.listeners.delete(o), !l.has(o))
|
||||||
return;
|
return;
|
||||||
let a = l.get(o);
|
let a = l.get(o);
|
||||||
a.delete(r), !(a.size > 1) && (g.clear(...a), l.delete(o));
|
a.delete(n), !(a.size > 1) && (g.clear(...a), l.delete(o));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
g.el = function(e, t) {
|
g.el = function(e, t) {
|
||||||
let r = document.createComment("<#reactive>"), n = document.createComment("</#reactive>"), o = document.createDocumentFragment();
|
let n = document.createComment("<#reactive>"), r = document.createComment("</#reactive>"), o = document.createDocumentFragment();
|
||||||
o.append(r, n);
|
o.append(n, r);
|
||||||
let a = (i) => {
|
let a = (i) => {
|
||||||
if (!r.parentNode || !n.parentNode)
|
if (!n.parentNode || !r.parentNode)
|
||||||
return U(e, a);
|
return $(e, a);
|
||||||
let s = t(i);
|
let s = t(i);
|
||||||
Array.isArray(s) || (s = [s]);
|
Array.isArray(s) || (s = [s]);
|
||||||
let h = r;
|
let h = n;
|
||||||
for (; (h = r.nextSibling) !== n; )
|
for (; (h = n.nextSibling) !== r; )
|
||||||
h.remove();
|
h.remove();
|
||||||
r.after(...s);
|
n.after(...s);
|
||||||
};
|
};
|
||||||
return P(e, a), a(e()), o;
|
return P(e, a), a(e()), o;
|
||||||
};
|
};
|
||||||
var z = {
|
var U = {
|
||||||
isTextContent(e) {
|
isTextContent(e) {
|
||||||
return w(e) === "string" || L(e) && w(X(e)) === "string";
|
return w(e) === "string" || R(e) && w(Y(e)) === "string";
|
||||||
},
|
},
|
||||||
processReactiveAttribute(e, t, r, n) {
|
processReactiveAttribute(e, t, n, r) {
|
||||||
return L(r) ? (P(r, (o) => n([t, o])), r()) : r;
|
return R(n) ? (P(n, (o) => r([t, o])), n()) : n;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function F(e, t) {
|
function z(e, t) {
|
||||||
let r = (...n) => n.length ? Q(r, n[0]) : K(r);
|
let n = (...r) => r.length ? X(n, r[0]) : Q(n);
|
||||||
return B(r, e, t);
|
return G(n, e, t);
|
||||||
}
|
}
|
||||||
var Z = Object.assign(/* @__PURE__ */ Object.create(null), {
|
var B = Object.assign(/* @__PURE__ */ Object.create(null), {
|
||||||
stopPropagation() {
|
stopPropagation() {
|
||||||
this.skip = !0;
|
this.skip = !0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function B(e, t, r) {
|
function G(e, t, n) {
|
||||||
return w(r) !== "[object Object]" && (r = {}), e[d] = {
|
return w(n) !== "[object Object]" && (n = {}), e[d] = {
|
||||||
value: t,
|
value: t,
|
||||||
actions: r,
|
actions: n,
|
||||||
listeners: /* @__PURE__ */ new Set()
|
listeners: /* @__PURE__ */ new Set()
|
||||||
}, e.toJSON = () => e(), Object.setPrototypeOf(e[d], Z), e;
|
}, e.toJSON = () => e(), Object.setPrototypeOf(e[d], B), e;
|
||||||
}
|
}
|
||||||
var R = [];
|
var A = [];
|
||||||
function G(e) {
|
function V(e) {
|
||||||
let t = function() {
|
let t = function() {
|
||||||
R.push(t), e(), R.pop();
|
A.push(t), e(), A.pop();
|
||||||
};
|
};
|
||||||
l.has(e) && (l.set(t, l.get(e)), l.delete(e)), t();
|
l.has(e) && (l.set(t, l.get(e)), l.delete(e)), t();
|
||||||
}
|
}
|
||||||
function V() {
|
function K() {
|
||||||
return R[R.length - 1];
|
return A[A.length - 1];
|
||||||
}
|
}
|
||||||
function K(e) {
|
function Q(e) {
|
||||||
if (!e[d])
|
if (!e[d])
|
||||||
return;
|
return;
|
||||||
let { value: t, listeners: r } = e[d], n = V();
|
let { value: t, listeners: n } = e[d], r = K();
|
||||||
return n && r.add(n), l.has(n) && l.get(n).add(e), t;
|
return r && n.add(r), l.has(r) && l.get(r).add(e), t;
|
||||||
}
|
}
|
||||||
function Q(e, t) {
|
function X(e, t) {
|
||||||
if (!e[d])
|
if (!e[d])
|
||||||
return;
|
return;
|
||||||
let r = e[d];
|
let n = e[d];
|
||||||
if (r.value !== t)
|
if (n.value !== t)
|
||||||
return r.value = t, r.listeners.forEach((n) => n(t)), t;
|
return n.value = t, n.listeners.forEach((r) => r(t)), t;
|
||||||
}
|
}
|
||||||
function X(e) {
|
function Y(e) {
|
||||||
return e[d].value;
|
return e[d].value;
|
||||||
}
|
}
|
||||||
function P(e, t) {
|
function P(e, t) {
|
||||||
if (e[d])
|
if (e[d])
|
||||||
return e[d].listeners.add(t);
|
return e[d].listeners.add(t);
|
||||||
}
|
}
|
||||||
function U(e, t) {
|
function $(e, t) {
|
||||||
if (e[d])
|
if (e[d])
|
||||||
return e[d].listeners.delete(t);
|
return e[d].listeners.delete(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// signals.js
|
// signals.js
|
||||||
_(z);
|
_(U);
|
||||||
export {
|
export {
|
||||||
g as S,
|
g as S,
|
||||||
y as assign,
|
y as assign,
|
||||||
q as classListDeclarative,
|
J as classListDeclarative,
|
||||||
ce as createElement,
|
ie as createElement,
|
||||||
ae as dispatchEvent,
|
de as dispatchEvent,
|
||||||
ce as el,
|
ie as el,
|
||||||
se as empty,
|
fe as empty,
|
||||||
L as isSignal,
|
R as isSignal,
|
||||||
oe as namespace,
|
ce as namespace,
|
||||||
k as on,
|
F as on,
|
||||||
_ as registerReactivity
|
_ as registerReactivity
|
||||||
};
|
};
|
||||||
|
100
dist/esm.js
vendored
100
dist/esm.js
vendored
@ -7,7 +7,7 @@ var g = {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function T(e, t = !0) {
|
function _(e, t = !0) {
|
||||||
return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e);
|
return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e);
|
||||||
}
|
}
|
||||||
function O(e) {
|
function O(e) {
|
||||||
@ -28,21 +28,21 @@ function L(e, t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/dom-common.js
|
// src/dom-common.js
|
||||||
var h = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), A = { setDelete: R };
|
var l = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]')), A = { setDeleteAttr: T };
|
||||||
function R(e, t, r) {
|
function T(e, t, r) {
|
||||||
Reflect.set(e, t, r), p(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
|
Reflect.set(e, t, r), p(r) && e.getAttribute(t) === "undefined" && e.removeAttribute(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/dom.js
|
// src/dom.js
|
||||||
var v = "html";
|
var v = "html";
|
||||||
function I(e) {
|
function Z(e) {
|
||||||
return v = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
return v = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
||||||
append(...t) {
|
append(...t) {
|
||||||
return v = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
|
return v = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function Z(e, t, ...r) {
|
function $(e, t, ...r) {
|
||||||
let n = O(this), c;
|
let n = O(this), c;
|
||||||
switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
|
switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
|
||||||
case typeof e == "function": {
|
case typeof e == "function": {
|
||||||
@ -50,31 +50,31 @@ function Z(e, t, ...r) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case e === "#text":
|
case e === "#text":
|
||||||
c = E(document.createTextNode(""), t);
|
c = b(document.createTextNode(""), t);
|
||||||
break;
|
break;
|
||||||
case e === "<>":
|
case e === "<>":
|
||||||
c = E(document.createDocumentFragment(), t);
|
c = b(document.createDocumentFragment(), t);
|
||||||
break;
|
break;
|
||||||
case v !== "html":
|
case v !== "html":
|
||||||
c = E(document.createElementNS(v, e), t);
|
c = b(document.createElementNS(v, e), t);
|
||||||
break;
|
break;
|
||||||
case !c:
|
case !c:
|
||||||
c = E(document.createElement(e), t);
|
c = b(document.createElement(e), t);
|
||||||
}
|
}
|
||||||
return r.forEach((a) => a(c)), c;
|
return r.forEach((a) => a(c)), c;
|
||||||
}
|
}
|
||||||
var { setDelete: y } = A;
|
var { setDeleteAttr: M } = A;
|
||||||
function E(e, ...t) {
|
function b(e, ...t) {
|
||||||
let r = O(this);
|
let r = O(this);
|
||||||
if (!t.length)
|
if (!t.length)
|
||||||
return e;
|
return e;
|
||||||
let n = e instanceof SVGElement, c = (n ? S : N).bind(null, e, "Attribute");
|
let n = e instanceof SVGElement, c = (n ? j : N).bind(null, e, "Attribute");
|
||||||
return Object.entries(Object.assign({}, ...t)).forEach(function a([s, f]) {
|
return Object.entries(Object.assign({}, ...t)).forEach(function a([s, f]) {
|
||||||
f = r.processReactiveAttribute(e, s, f, a);
|
f = r.processReactiveAttribute(e, s, f, a);
|
||||||
let [l] = s;
|
let [h] = s;
|
||||||
if (l === "=")
|
if (h === "=")
|
||||||
return c(s.slice(1), f);
|
return c(s.slice(1), f);
|
||||||
if (l === ".")
|
if (h === ".")
|
||||||
return y(e, s.slice(1), f);
|
return y(e, s.slice(1), f);
|
||||||
if (typeof f == "object")
|
if (typeof f == "object")
|
||||||
switch (s) {
|
switch (s) {
|
||||||
@ -83,9 +83,9 @@ function E(e, ...t) {
|
|||||||
case "dataset":
|
case "dataset":
|
||||||
return m(f, y.bind(null, e.dataset));
|
return m(f, y.bind(null, e.dataset));
|
||||||
case "ariaset":
|
case "ariaset":
|
||||||
return m(f, (x, b) => c("aria-" + x, b));
|
return m(f, (x, E) => c("aria-" + x, E));
|
||||||
case "classList":
|
case "classList":
|
||||||
return j(e, f);
|
return P(e, f);
|
||||||
default:
|
default:
|
||||||
return Reflect.set(e, s, f);
|
return Reflect.set(e, s, f);
|
||||||
}
|
}
|
||||||
@ -101,27 +101,27 @@ function E(e, ...t) {
|
|||||||
break;
|
break;
|
||||||
return e.appendChild(document.createTextNode(f));
|
return e.appendChild(document.createTextNode(f));
|
||||||
}
|
}
|
||||||
return M(e, s) ? y(e, s, f) : c(s, f);
|
return S(e, s) ? M(e, s, f) : c(s, f);
|
||||||
}), e;
|
}), e;
|
||||||
}
|
}
|
||||||
function j(e, t) {
|
function P(e, t) {
|
||||||
return typeof t != "object" || m(
|
return typeof t != "object" || m(
|
||||||
t,
|
t,
|
||||||
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
|
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
|
||||||
), e;
|
), e;
|
||||||
}
|
}
|
||||||
function B(e) {
|
function G(e) {
|
||||||
return Array.from(e.children).forEach((t) => t.remove()), e;
|
return Array.from(e.children).forEach((t) => t.remove()), e;
|
||||||
}
|
}
|
||||||
function M(e, t) {
|
function S(e, t) {
|
||||||
let r = "HTMLElement," + t;
|
let r = "HTMLElement," + t;
|
||||||
if (e instanceof HTMLElement && h.has(r))
|
if (e instanceof HTMLElement && l.has(r))
|
||||||
return h.get(r);
|
return l.get(r);
|
||||||
let n = e.nodeName + "," + t;
|
let n = e.nodeName + "," + t;
|
||||||
if (h.has(n))
|
if (l.has(n))
|
||||||
return h.get(n);
|
return l.get(n);
|
||||||
let [c, a, s] = D(e, t), f = !p(c.set);
|
let [c, a, s] = D(e, t), f = !p(c.set);
|
||||||
return (!f || a) && h.set(s === HTMLElement.prototype ? r : n, f), f;
|
return (!f || a) && l.set(s === HTMLElement.prototype ? r : n, f), f;
|
||||||
}
|
}
|
||||||
function D(e, t, r = 0) {
|
function D(e, t, r = 0) {
|
||||||
if (e = Object.getPrototypeOf(e), !e)
|
if (e = Object.getPrototypeOf(e), !e)
|
||||||
@ -130,37 +130,41 @@ function D(e, t, r = 0) {
|
|||||||
return n ? [n, r, e] : D(e, t, r + 1);
|
return n ? [n, r, e] : D(e, t, r + 1);
|
||||||
}
|
}
|
||||||
function m(e, t) {
|
function m(e, t) {
|
||||||
return Object.entries(e).forEach(([r, n]) => t(r, n));
|
return Object.entries(e).forEach(([r, n]) => r && t(r, n));
|
||||||
}
|
}
|
||||||
function N(e, t, r, n) {
|
function N(e, t, r, n) {
|
||||||
return e[(p(n) ? "remove" : "set") + t](r, n);
|
return e[(p(n) ? "remove" : "set") + t](r, n);
|
||||||
}
|
}
|
||||||
function S(e, t, r, n, c = null) {
|
function j(e, t, r, n, c = null) {
|
||||||
return e[(p(n) ? "remove" : "set") + t + "NS"](c, r, n);
|
return e[(p(n) ? "remove" : "set") + t + "NS"](c, r, n);
|
||||||
}
|
}
|
||||||
|
function y(e, t, r) {
|
||||||
|
if (Reflect.set(e, t, r), !!p(r))
|
||||||
|
return Reflect.deleteProperty(e, t);
|
||||||
|
}
|
||||||
|
|
||||||
// src/events.js
|
// src/events.js
|
||||||
function V(e, t, ...r) {
|
function W(e, t, ...r) {
|
||||||
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
|
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t);
|
||||||
return e.dispatchEvent(n);
|
return e.dispatchEvent(n);
|
||||||
}
|
}
|
||||||
function _(e, t, r) {
|
function R(e, t, r) {
|
||||||
return function(c) {
|
return function(c) {
|
||||||
return c.addEventListener(e, t, r), c;
|
return c.addEventListener(e, t, r), c;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var w = P();
|
var w = H();
|
||||||
_.connected = function(e, t) {
|
R.connected = function(e, t) {
|
||||||
return function(n) {
|
return function(n) {
|
||||||
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (L(t && t.signal, () => w.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : w.onConnected(n, e)), n);
|
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (L(t && t.signal, () => w.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : w.onConnected(n, e)), n);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
_.disconnected = function(e, t) {
|
R.disconnected = function(e, t) {
|
||||||
return function(n) {
|
return function(n) {
|
||||||
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (L(t && t.signal, () => w.offDisconnected(n, e)) && w.onDisconnected(n, e), n);
|
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (L(t && t.signal, () => w.offDisconnected(n, e)) && w.onDisconnected(n, e), n);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
function P() {
|
function H() {
|
||||||
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) {
|
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) {
|
||||||
for (let i of o)
|
for (let i of o)
|
||||||
if (i.type === "childList") {
|
if (i.type === "childList") {
|
||||||
@ -168,7 +172,7 @@ function P() {
|
|||||||
s();
|
s();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
b(i.removedNodes, !0) && s();
|
E(i.removedNodes, !0) && s();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
@ -211,7 +215,7 @@ function P() {
|
|||||||
(requestIdleCallback || requestAnimationFrame)(o);
|
(requestIdleCallback || requestAnimationFrame)(o);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async function l(o) {
|
async function h(o) {
|
||||||
e.size > 30 && await f();
|
e.size > 30 && await f();
|
||||||
let i = [];
|
let i = [];
|
||||||
if (!(o instanceof Node))
|
if (!(o instanceof Node))
|
||||||
@ -222,16 +226,16 @@ function P() {
|
|||||||
}
|
}
|
||||||
function x(o, i) {
|
function x(o, i) {
|
||||||
for (let u of o) {
|
for (let u of o) {
|
||||||
if (i && l(u).then(x), !e.has(u))
|
if (i && h(u).then(x), !e.has(u))
|
||||||
continue;
|
continue;
|
||||||
let d = e.get(u);
|
let d = e.get(u);
|
||||||
return d.connected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length || e.delete(u), !0;
|
return d.connected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length || e.delete(u), !0;
|
||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
function b(o, i) {
|
function E(o, i) {
|
||||||
for (let u of o) {
|
for (let u of o) {
|
||||||
if (i && l(u).then(b), !e.has(u))
|
if (i && h(u).then(E), !e.has(u))
|
||||||
continue;
|
continue;
|
||||||
let d = e.get(u);
|
let d = e.get(u);
|
||||||
return d.disconnected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length = 0, e.delete(u), !0;
|
return d.disconnected.forEach((C) => C(u)), d.connected.length = 0, d.disconnected.length = 0, e.delete(u), !0;
|
||||||
@ -248,13 +252,13 @@ function P() {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
export {
|
export {
|
||||||
E as assign,
|
b as assign,
|
||||||
j as classListDeclarative,
|
P as classListDeclarative,
|
||||||
Z as createElement,
|
$ as createElement,
|
||||||
V as dispatchEvent,
|
W as dispatchEvent,
|
||||||
Z as el,
|
$ as el,
|
||||||
B as empty,
|
G as empty,
|
||||||
I as namespace,
|
Z as namespace,
|
||||||
_ as on,
|
R as on,
|
||||||
T as registerReactivity
|
_ as registerReactivity
|
||||||
};
|
};
|
||||||
|
6
jsdom.js
6
jsdom.js
@ -1,9 +1,9 @@
|
|||||||
//TODO: https://www.npmjs.com/package/html-element
|
//TODO: https://www.npmjs.com/package/html-element
|
||||||
import { prop_process } from './src/dom-common.js';
|
import { prop_process } from './src/dom-common.js';
|
||||||
const { setDelete }= prop_process;
|
const { setDeleteAttr }= prop_process;
|
||||||
/** @param {HTMLElement} obj */
|
/** @param {HTMLElement} obj */
|
||||||
prop_process.setDelete= function(obj, prop, value){
|
prop_process.setDeleteAttr= function(obj, prop, value){
|
||||||
if("checked"!==prop) return setDelete(obj, prop, value);
|
if("checked"!==prop) return setDeleteAttr(obj, prop, value);
|
||||||
if(value) return obj.setAttribute("checked", "");
|
if(value) return obj.setAttribute("checked", "");
|
||||||
obj.removeAttribute("checked");
|
obj.removeAttribute("checked");
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "deka-dom-el",
|
"name": "deka-dom-el",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"description": "A low-code library that simplifies the creation of native DOM elements/components using small wrappers and tweaks.",
|
"description": "A low-code library that simplifies the creation of native DOM elements/components using small wrappers and tweaks.",
|
||||||
"author": "Jan Andrle <andrle.jan@centrum.cz>",
|
"author": "Jan Andrle <andrle.jan@centrum.cz>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/** @type {Map<string, boolean>} */
|
/** @type {Map<string, boolean>} */
|
||||||
export const prop_cache= new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]'));
|
export const prop_cache= new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]'));
|
||||||
export const prop_process= { setDelete };
|
export const prop_process= { setDeleteAttr };
|
||||||
import { isUndef } from './helpers.js';
|
import { isUndef } from './helpers.js';
|
||||||
function setDelete(obj, prop, val){
|
function setDeleteAttr(obj, prop, val){
|
||||||
/* Issue
|
/* Issue
|
||||||
For some native attrs you can unset only to set empty string.
|
For some native attrs you can unset only to set empty string.
|
||||||
This can be confusing as it is seen in inspector `<… id=""`.
|
This can be confusing as it is seen in inspector `<… id=""`.
|
||||||
|
@ -36,7 +36,7 @@ export function createElement(tag, attributes, ...connect){
|
|||||||
export { createElement as el };
|
export { createElement as el };
|
||||||
|
|
||||||
import { prop_cache, prop_process } from './dom-common.js';
|
import { prop_cache, prop_process } from './dom-common.js';
|
||||||
const { setDelete }= prop_process;
|
const { setDeleteAttr }= prop_process;
|
||||||
export function assign(element, ...attributes){
|
export function assign(element, ...attributes){
|
||||||
const s= signals(this);
|
const s= signals(this);
|
||||||
if(!attributes.length) return element;
|
if(!attributes.length) return element;
|
||||||
@ -71,7 +71,7 @@ export function assign(element, ...attributes){
|
|||||||
if(!is_svg) break;
|
if(!is_svg) break;
|
||||||
return element.appendChild(document.createTextNode(attr));
|
return element.appendChild(document.createTextNode(attr));
|
||||||
}
|
}
|
||||||
return isPropSetter(element, key) ? setDelete(element, key, attr) : setRemoveAttr(key, attr);
|
return isPropSetter(element, key) ? setDeleteAttr(element, key, attr) : setRemoveAttr(key, attr);
|
||||||
});
|
});
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,8 @@ function getPropDescriptor(p, key, level= 0){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @template {Record<any, any>} T @param {T} obj @param {(param: [ keyof T, T[keyof T] ])=> void} cb */
|
/** @template {Record<any, any>} T @param {T} obj @param {(param: [ keyof T, T[keyof T] ])=> void} cb */
|
||||||
function forEachEntries(obj, cb){ return Object.entries(obj).forEach(([ key, val ])=> cb(key, val)); }
|
function forEachEntries(obj, cb){ return Object.entries(obj).forEach(([ key, val ])=> key && cb(key, val)); }
|
||||||
|
|
||||||
function setRemove(obj, prop, key, val){ return obj[ (isUndef(val) ? "remove" : "set") + prop ](key, val); }
|
function setRemove(obj, prop, key, val){ return obj[ (isUndef(val) ? "remove" : "set") + prop ](key, val); }
|
||||||
function setRemoveNS(obj, prop, key, val, ns= null){ return obj[ (isUndef(val) ? "remove" : "set") + prop + "NS" ](ns, key, val); }
|
function setRemoveNS(obj, prop, key, val, ns= null){ return obj[ (isUndef(val) ? "remove" : "set") + prop + "NS" ](ns, key, val); }
|
||||||
|
function setDelete(obj, key, val){ Reflect.set(obj, key, val); if(!isUndef(val)) return; return Reflect.deleteProperty(obj, key); }
|
||||||
|
Loading…
Reference in New Issue
Block a user