1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-21 23:39:37 +01:00

Add __dde_lifecycleToEvents flag to lifecycleToEvents

This commit is contained in:
Jan Andrle 2023-10-13 16:51:43 +02:00
parent 18f93d7e0b
commit 06ab87c06f
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
6 changed files with 176 additions and 178 deletions

View File

@ -1,7 +1,7 @@
//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 y = { var w = {
isSignal(e) { isSignal(e) {
return !1; return !1;
}, },
@ -10,10 +10,10 @@
} }
}; };
function N(e, t = !0) { function N(e, t = !0) {
return t ? Object.assign(y, e) : (Object.setPrototypeOf(e, y), e); return t ? Object.assign(w, e) : (Object.setPrototypeOf(e, w), e);
} }
function _(e) { function x(e) {
return y.isPrototypeOf(e) && e !== y ? e : y; return w.isPrototypeOf(e) && e !== w ? e : w;
} }
// src/helpers.js // src/helpers.js
@ -34,8 +34,8 @@
} }
// src/dom-common.js // src/dom-common.js
var W = { setDeleteAttr: H }; var T = { setDeleteAttr: k };
function H(e, t, n) { function k(e, t, n) {
if (Reflect.set(e, t, n), !!v(n)) { if (Reflect.set(e, t, n), !!v(n)) {
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined") if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t); return e.removeAttribute(t);
@ -45,12 +45,12 @@
} }
// src/dom.js // src/dom.js
var S = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.body) : document.body }], M = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, E = { var y = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.body) : document.body }], W = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, E = {
get current() { get current() {
return S[S.length - 1]; return y[y.length - 1];
}, },
get state() { get state() {
return [...S]; return [...y];
}, },
get host() { get host() {
return this.current.host; return this.current.host;
@ -59,7 +59,7 @@
return this.current.namespace; return this.current.namespace;
}, },
set namespace(e) { set namespace(e) {
return this.current.namespace = M(e); return this.current.namespace = W(e);
}, },
elNamespace(e) { elNamespace(e) {
let t = this.namespace; let t = this.namespace;
@ -70,14 +70,14 @@
}; };
}, },
push(e = {}) { push(e = {}) {
return e.namespace && (e.namespace = M(e.namespace)), S.push(Object.assign({}, this.current, e)); return e.namespace && (e.namespace = W(e.namespace)), y.push(Object.assign({}, this.current, e));
}, },
pop() { pop() {
return S.pop(); return y.pop();
} }
}; };
function ie(e, t, ...n) { function ie(e, t, ...n) {
let r = this, o = _(this), { namespace: c } = E, a; let r = this, o = x(this), { namespace: c } = E, a;
switch ((Object(t) !== t || o.isSignal(t)) && (t = { textContent: t }), !0) { switch ((Object(t) !== t || o.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
E.push({ scope: e, host: (s) => s ? (n.unshift(s), void 0) : a }), a = e(t || void 0), E.pop(); E.push({ scope: e, host: (s) => s ? (n.unshift(s), void 0) : a }), a = e(t || void 0), E.pop();
@ -97,9 +97,9 @@
} }
return n.forEach((s) => s(a)), a; return n.forEach((s) => s(a)), a;
} }
var { setDeleteAttr: k } = W; var { setDeleteAttr: M } = T;
function O(e, ...t) { function O(e, ...t) {
let n = this, r = _(this); let n = this, r = x(this);
if (!t.length) if (!t.length)
return e; return e;
let c = (e instanceof SVGElement ? J : I).bind(null, e, "Attribute"); let c = (e instanceof SVGElement ? J : I).bind(null, e, "Attribute");
@ -116,7 +116,7 @@
case "xlink:href": case "xlink:href":
return c(s, d, "http://www.w3.org/1999/xlink"); return c(s, d, "http://www.w3.org/1999/xlink");
case "textContent": case "textContent":
return k(e, s, d); return M(e, s, d);
case "style": case "style":
if (typeof d != "object") if (typeof d != "object")
break; break;
@ -127,11 +127,11 @@
case "classList": case "classList":
return B.call(n, e, d); return B.call(n, e, d);
} }
return G(e, s) ? k(e, s, d) : c(s, d); return G(e, s) ? M(e, s, d) : c(s, d);
}), e; }), e;
} }
function B(e, t) { function B(e, t) {
let n = _(this); let n = x(this);
return D( return D(
n, n,
t, t,
@ -159,14 +159,14 @@
o && (c = e.processReactiveAttribute(t, o, c, (a) => n(...a)), n(o, c)); o && (c = e.processReactiveAttribute(t, o, c, (a) => n(...a)), n(o, c));
}); });
} }
function T(e) { function U(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e; return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
} }
function I(e, t, n, r) { function I(e, t, n, r) {
return e[(v(r) ? "remove" : "set") + t](n, T(r)); return e[(v(r) ? "remove" : "set") + t](n, U(r));
} }
function J(e, t, n, r, o = null) { function J(e, t, n, r, o = null) {
return e[(v(r) ? "remove" : "set") + t + "NS"](o, n, T(r)); return e[(v(r) ? "remove" : "set") + t + "NS"](o, n, U(r));
} }
function F(e, t, n) { function F(e, t, n) {
if (Reflect.set(e, t, n), !!v(n)) if (Reflect.set(e, t, n), !!v(n))
@ -178,31 +178,31 @@
let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t); let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(r); return e.dispatchEvent(r);
} }
function x(e, t, n) { function S(e, t, n) {
return function(o) { return function(o) {
return o.addEventListener(e, t, n), o; return o.addEventListener(e, t, n), o;
}; };
} }
var R = Z(), V = /* @__PURE__ */ new WeakSet(); var R = Z(), V = /* @__PURE__ */ new WeakSet();
x.connected = function(e, t) { S.connected = function(e, t) {
let n = "connected"; let n = "connected";
return typeof t != "object" && (t = {}), t.once = !0, function(o) { return typeof t != "object" && (t = {}), t.once = !0, function(o) {
let c = "dde:" + n; let c = "dde:" + n;
return o.addEventListener(c, e, t), typeof o[n + "Callback"] == "function" ? o : o.isConnected ? (o.dispatchEvent(new Event(c)), o) : (A(t.signal, () => R.offConnected(o, e)) && R.onConnected(o, e), o); return o.addEventListener(c, e, t), o.__dde_lifecycleToEvents ? o : o.isConnected ? (o.dispatchEvent(new Event(c)), o) : (A(t.signal, () => R.offConnected(o, e)) && R.onConnected(o, e), o);
}; };
}; };
x.disconnected = function(e, t) { S.disconnected = function(e, t) {
let n = "disconnected"; let n = "disconnected";
return typeof t != "object" && (t = {}), t.once = !0, function(o) { return typeof t != "object" && (t = {}), t.once = !0, function(o) {
let c = "dde:" + n; let c = "dde:" + n;
return o.addEventListener(c, e, t), typeof o[n + "Callback"] == "function" || A(t.signal, () => R.offDisconnected(o, e)) && R.onDisconnected(o, e), o; return o.addEventListener(c, e, t), o.__dde_lifecycleToEvents || A(t.signal, () => R.offDisconnected(o, e)) && R.onDisconnected(o, e), o;
}; };
}; };
x.attributeChanged = function(e, t) { S.attributeChanged = function(e, t) {
let n = "attributeChanged"; let n = "attributeChanged";
return typeof t != "object" && (t = {}), function(o) { return typeof t != "object" && (t = {}), function(o) {
let c = "dde:" + n; let c = "dde:" + n;
if (o.addEventListener(c, e, t), typeof o[n + "Callback"] == "function" || V.has(o)) if (o.addEventListener(c, e, t), o.__dde_lifecycleToEvents || V.has(o))
return o; return o;
let a = new MutationObserver(function(d) { let a = new MutationObserver(function(d) {
for (let { attributeName: m, target: b } of d) for (let { attributeName: m, target: b } of d)
@ -287,8 +287,8 @@
for (let p of i) { for (let p of i) {
if (u && d(p).then(m), !e.has(p)) if (u && d(p).then(m), !e.has(p))
continue; continue;
let w = e.get(p); let _ = e.get(p);
w.length_c && (p.dispatchEvent(new Event("dde:connected")), w.connected = /* @__PURE__ */ new WeakSet(), w.length_c = 0, w.length_d || e.delete(p), f = !0); _.length_c && (p.dispatchEvent(new Event("dde:connected")), _.connected = /* @__PURE__ */ new WeakSet(), _.length_c = 0, _.length_d || e.delete(p), f = !0);
} }
return f; return f;
} }
@ -320,10 +320,10 @@
var g = /* @__PURE__ */ new WeakMap(); var g = /* @__PURE__ */ new WeakMap();
function h(e, t) { function h(e, t) {
if (typeof e != "function") if (typeof e != "function")
return U(e, t); return $(e, t);
if (C(e)) if (C(e))
return e; return e;
let n = U(""), r = () => n(e()); let n = $(""), r = () => n(e());
return g.set(r, /* @__PURE__ */ new Set([n])), X(r), n; return g.set(r, /* @__PURE__ */ new Set([n])), X(r), n;
} }
h.action = function(e, t, ...n) { h.action = function(e, t, ...n) {
@ -339,7 +339,7 @@
if (!(o && o.aborted)) { if (!(o && o.aborted)) {
if (Array.isArray(t)) if (Array.isArray(t))
return t.forEach((c) => e(c, n, r)); return t.forEach((c) => e(c, n, r));
P(t, n), o && o.addEventListener("abort", () => q(t, n)); P(t, n), o && o.addEventListener("abort", () => H(t, n));
} }
}; };
h.symbols = { h.symbols = {
@ -352,7 +352,7 @@
o.abort(); o.abort();
} }
}); });
return E.host(x.attributeChanged(function({ detail: a }) { return E.host(S.attributeChanged(function({ detail: a }) {
let [s, d] = a; let [s, d] = a;
s === e && c(d); s === e && c(d);
}, { signal: o.signal })), c; }, { signal: o.signal })), c;
@ -377,7 +377,7 @@
o.append(n, r); o.append(n, r);
let c = (a) => { let c = (a) => {
if (!n.parentNode || !r.parentNode) if (!n.parentNode || !r.parentNode)
return q(e, c); return H(e, c);
let s = t(a); let s = t(a);
Array.isArray(s) || (s = [s]); Array.isArray(s) || (s = [s]);
let d = n; let d = n;
@ -387,13 +387,13 @@
}; };
return P(e, c), c(e()), o; return P(e, c), c(e()), o;
}; };
var $ = { var q = {
isSignal: C, isSignal: C,
processReactiveAttribute(e, t, n, r) { processReactiveAttribute(e, t, n, r) {
return C(n) ? (P(n, (o) => r([t, o])), n()) : n; return C(n) ? (P(n, (o) => r([t, o])), n()) : n;
} }
}; };
function U(e, t) { function $(e, t) {
let n = (...r) => r.length ? te(n, ...r) : ee(n); let n = (...r) => r.length ? te(n, ...r) : ee(n);
return Q(n, e, t); return Q(n, e, t);
} }
@ -436,13 +436,13 @@
if (e[l]) if (e[l])
return e[l].listeners.add(t); return e[l].listeners.add(t);
} }
function q(e, t) { function H(e, t) {
if (e[l]) if (e[l])
return e[l].listeners.delete(t); return e[l].listeners.delete(t);
} }
// signals.js // signals.js
N($); N(q);
globalThis.dde= { globalThis.dde= {
S: h, S: h,
@ -453,7 +453,7 @@
el: ie, el: ie,
empty: fe, empty: fe,
isSignal: C, isSignal: C,
on: x, on: S,
registerReactivity: N, registerReactivity: N,
scope: E scope: E
}; };

90
dist/dde.js vendored
View File

@ -1,7 +1,7 @@
//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 b = { var m = {
isSignal(e) { isSignal(e) {
return !1; return !1;
}, },
@ -10,17 +10,17 @@
} }
}; };
function P(e, t = !0) { function P(e, t = !0) {
return t ? Object.assign(b, e) : (Object.setPrototypeOf(e, b), e); return t ? Object.assign(m, e) : (Object.setPrototypeOf(e, m), e);
} }
function E(e) { function b(e) {
return b.isPrototypeOf(e) && e !== b ? e : b; return m.isPrototypeOf(e) && e !== m ? e : m;
} }
// src/helpers.js // src/helpers.js
function g(e) { function g(e) {
return typeof e > "u"; return typeof e > "u";
} }
function w(e, t) { function _(e, t) {
if (!e || !(e instanceof AbortSignal)) if (!e || !(e instanceof AbortSignal))
return !0; return !0;
if (!e.aborted) if (!e.aborted)
@ -30,7 +30,7 @@
} }
// src/dom-common.js // src/dom-common.js
var y = { setDeleteAttr: j }; var C = { setDeleteAttr: j };
function j(e, t, n) { function j(e, t, n) {
if (Reflect.set(e, t, n), !!g(n)) { if (Reflect.set(e, t, n), !!g(n)) {
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined") if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
@ -41,12 +41,12 @@
} }
// src/dom.js // src/dom.js
var m = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.body) : document.body }], R = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, _ = { var E = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.body) : document.body }], R = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, x = {
get current() { get current() {
return m[m.length - 1]; return E[E.length - 1];
}, },
get state() { get state() {
return [...m]; return [...E];
}, },
get host() { get host() {
return this.current.host; return this.current.host;
@ -61,44 +61,44 @@
let t = this.namespace; let t = this.namespace;
return this.namespace = e, { return this.namespace = e, {
append(...n) { append(...n) {
return _.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n); return x.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
} }
}; };
}, },
push(e = {}) { push(e = {}) {
return e.namespace && (e.namespace = R(e.namespace)), m.push(Object.assign({}, this.current, e)); return e.namespace && (e.namespace = R(e.namespace)), E.push(Object.assign({}, this.current, e));
}, },
pop() { pop() {
return m.pop(); return E.pop();
} }
}; };
function V(e, t, ...n) { function V(e, t, ...n) {
let s = this, r = E(this), { namespace: f } = _, a; let s = this, r = b(this), { namespace: f } = x, a;
switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) { switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
_.push({ scope: e, host: (u) => u ? (n.unshift(u), void 0) : a }), a = e(t || void 0), _.pop(); x.push({ scope: e, host: (u) => u ? (n.unshift(u), void 0) : a }), a = e(t || void 0), x.pop();
break; break;
} }
case e === "#text": case e === "#text":
a = x.call(s, document.createTextNode(""), t); a = w.call(s, document.createTextNode(""), t);
break; break;
case e === "<>": case e === "<>":
a = x.call(s, document.createDocumentFragment(), t); a = w.call(s, document.createDocumentFragment(), t);
break; break;
case f !== "html": case f !== "html":
a = x.call(s, document.createElementNS(f, e), t); a = w.call(s, document.createElementNS(f, e), t);
break; break;
case !a: case !a:
a = x.call(s, document.createElement(e), t); a = w.call(s, document.createElement(e), t);
} }
return n.forEach((u) => u(a)), a; return n.forEach((u) => u(a)), a;
} }
var { setDeleteAttr: S } = y; var { setDeleteAttr: S } = C;
function x(e, ...t) { function w(e, ...t) {
let n = this, s = E(this); let n = this, s = b(this);
if (!t.length) if (!t.length)
return e; return e;
let f = (e instanceof SVGElement ? T : F).bind(null, e, "Attribute"); let f = (e instanceof SVGElement ? F : W).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function a([u, d]) { return Object.entries(Object.assign({}, ...t)).forEach(function a([u, d]) {
d = s.processReactiveAttribute(e, u, d, a); d = s.processReactiveAttribute(e, u, d, a);
let [h] = u; let [h] = u;
@ -117,18 +117,18 @@
if (typeof d != "object") if (typeof d != "object")
break; break;
case "dataset": case "dataset":
return C(s, d, L.bind(null, e[u])); return O(s, d, L.bind(null, e[u]));
case "ariaset": case "ariaset":
return C(s, d, (l, c) => f("aria-" + l, c)); return O(s, d, (l, c) => f("aria-" + l, c));
case "classList": case "classList":
return M.call(n, e, d); return T.call(n, e, d);
} }
return W(e, u) ? S(e, u, d) : f(u, d); return M(e, u) ? S(e, u, d) : f(u, d);
}), e; }), e;
} }
function M(e, t) { function T(e, t) {
let n = E(this); let n = b(this);
return C( return O(
n, n,
t, t,
(s, r) => e.classList.toggle(s, r === -1 ? void 0 : !!r) (s, r) => e.classList.toggle(s, r === -1 ? void 0 : !!r)
@ -137,7 +137,7 @@
function $(e) { function $(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function W(e, t) { function M(e, t) {
if (!Reflect.has(e, t)) if (!Reflect.has(e, t))
return !1; return !1;
let n = D(e, t); let n = D(e, t);
@ -149,7 +149,7 @@
let n = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return n || D(e, t); return n || D(e, t);
} }
function C(e, t, n) { function O(e, t, n) {
if (!(typeof t != "object" || t === null)) if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([r, f]) { return Object.entries(t).forEach(function([r, f]) {
r && (f = e.processReactiveAttribute(t, r, f, (a) => n(...a)), n(r, f)); r && (f = e.processReactiveAttribute(t, r, f, (a) => n(...a)), n(r, f));
@ -158,10 +158,10 @@
function N(e) { function N(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e; return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
} }
function F(e, t, n, s) { function W(e, t, n, s) {
return e[(g(s) ? "remove" : "set") + t](n, N(s)); return e[(g(s) ? "remove" : "set") + t](n, N(s));
} }
function T(e, t, n, s, r = null) { function F(e, t, n, s, r = null) {
return e[(g(s) ? "remove" : "set") + t + "NS"](r, n, N(s)); return e[(g(s) ? "remove" : "set") + t + "NS"](r, n, N(s));
} }
function L(e, t, n) { function L(e, t, n) {
@ -174,31 +174,31 @@
let s = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t); let s = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(s); return e.dispatchEvent(s);
} }
function O(e, t, n) { function y(e, t, n) {
return function(r) { return function(r) {
return r.addEventListener(e, t, n), r; return r.addEventListener(e, t, n), r;
}; };
} }
var A = q(), U = /* @__PURE__ */ new WeakSet(); var A = q(), U = /* @__PURE__ */ new WeakSet();
O.connected = function(e, t) { y.connected = function(e, t) {
let n = "connected"; let n = "connected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) { return typeof t != "object" && (t = {}), t.once = !0, function(r) {
let f = "dde:" + n; let f = "dde:" + n;
return r.addEventListener(f, e, t), typeof r[n + "Callback"] == "function" ? r : r.isConnected ? (r.dispatchEvent(new Event(f)), r) : (w(t.signal, () => A.offConnected(r, e)) && A.onConnected(r, e), r); return r.addEventListener(f, e, t), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(f)), r) : (_(t.signal, () => A.offConnected(r, e)) && A.onConnected(r, e), r);
}; };
}; };
O.disconnected = function(e, t) { y.disconnected = function(e, t) {
let n = "disconnected"; let n = "disconnected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) { return typeof t != "object" && (t = {}), t.once = !0, function(r) {
let f = "dde:" + n; let f = "dde:" + n;
return r.addEventListener(f, e, t), typeof r[n + "Callback"] == "function" || w(t.signal, () => A.offDisconnected(r, e)) && A.onDisconnected(r, e), r; return r.addEventListener(f, e, t), r.__dde_lifecycleToEvents || _(t.signal, () => A.offDisconnected(r, e)) && A.onDisconnected(r, e), r;
}; };
}; };
O.attributeChanged = function(e, t) { y.attributeChanged = function(e, t) {
let n = "attributeChanged"; let n = "attributeChanged";
return typeof t != "object" && (t = {}), function(r) { return typeof t != "object" && (t = {}), function(r) {
let f = "dde:" + n; let f = "dde:" + n;
if (r.addEventListener(f, e, t), typeof r[n + "Callback"] == "function" || U.has(r)) if (r.addEventListener(f, e, t), r.__dde_lifecycleToEvents || U.has(r))
return r; return r;
let a = new MutationObserver(function(d) { let a = new MutationObserver(function(d) {
for (let { attributeName: h, target: l } of d) for (let { attributeName: h, target: l } of d)
@ -206,7 +206,7 @@
new CustomEvent(f, { detail: [h, l.getAttribute(h)] }) new CustomEvent(f, { detail: [h, l.getAttribute(h)] })
); );
}); });
return w(t.signal, () => a.disconnect()) && a.observe(r, { attributes: !0 }), r; return _(t.signal, () => a.disconnect()) && a.observe(r, { attributes: !0 }), r;
}; };
}; };
function q() { function q() {
@ -305,15 +305,15 @@
}); });
globalThis.dde= { globalThis.dde= {
assign: x, assign: w,
classListDeclarative: M, classListDeclarative: T,
createElement: V, createElement: V,
dispatchEvent: Q, dispatchEvent: Q,
el: V, el: V,
empty: $, empty: $,
on: O, on: y,
registerReactivity: P, registerReactivity: P,
scope: _ scope: x
}; };
})(); })();

View File

@ -1,5 +1,5 @@
// src/signals-common.js // src/signals-common.js
var y = { var w = {
isSignal(e) { isSignal(e) {
return !1; return !1;
}, },
@ -8,10 +8,10 @@ var y = {
} }
}; };
function N(e, t = !0) { function N(e, t = !0) {
return t ? Object.assign(y, e) : (Object.setPrototypeOf(e, y), e); return t ? Object.assign(w, e) : (Object.setPrototypeOf(e, w), e);
} }
function _(e) { function x(e) {
return y.isPrototypeOf(e) && e !== y ? e : y; return w.isPrototypeOf(e) && e !== w ? e : w;
} }
// src/helpers.js // src/helpers.js
@ -32,8 +32,8 @@ function A(e, t) {
} }
// src/dom-common.js // src/dom-common.js
var W = { setDeleteAttr: H }; var T = { setDeleteAttr: k };
function H(e, t, n) { function k(e, t, n) {
if (Reflect.set(e, t, n), !!v(n)) { if (Reflect.set(e, t, n), !!v(n)) {
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined") if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t); return e.removeAttribute(t);
@ -43,12 +43,12 @@ function H(e, t, n) {
} }
// src/dom.js // src/dom.js
var S = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.body) : document.body }], M = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, E = { var y = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.body) : document.body }], W = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, E = {
get current() { get current() {
return S[S.length - 1]; return y[y.length - 1];
}, },
get state() { get state() {
return [...S]; return [...y];
}, },
get host() { get host() {
return this.current.host; return this.current.host;
@ -57,7 +57,7 @@ var S = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.
return this.current.namespace; return this.current.namespace;
}, },
set namespace(e) { set namespace(e) {
return this.current.namespace = M(e); return this.current.namespace = W(e);
}, },
elNamespace(e) { elNamespace(e) {
let t = this.namespace; let t = this.namespace;
@ -68,14 +68,14 @@ var S = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.
}; };
}, },
push(e = {}) { push(e = {}) {
return e.namespace && (e.namespace = M(e.namespace)), S.push(Object.assign({}, this.current, e)); return e.namespace && (e.namespace = W(e.namespace)), y.push(Object.assign({}, this.current, e));
}, },
pop() { pop() {
return S.pop(); return y.pop();
} }
}; };
function ie(e, t, ...n) { function ie(e, t, ...n) {
let r = this, o = _(this), { namespace: c } = E, a; let r = this, o = x(this), { namespace: c } = E, a;
switch ((Object(t) !== t || o.isSignal(t)) && (t = { textContent: t }), !0) { switch ((Object(t) !== t || o.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
E.push({ scope: e, host: (s) => s ? (n.unshift(s), void 0) : a }), a = e(t || void 0), E.pop(); E.push({ scope: e, host: (s) => s ? (n.unshift(s), void 0) : a }), a = e(t || void 0), E.pop();
@ -95,9 +95,9 @@ function ie(e, t, ...n) {
} }
return n.forEach((s) => s(a)), a; return n.forEach((s) => s(a)), a;
} }
var { setDeleteAttr: k } = W; var { setDeleteAttr: M } = T;
function O(e, ...t) { function O(e, ...t) {
let n = this, r = _(this); let n = this, r = x(this);
if (!t.length) if (!t.length)
return e; return e;
let c = (e instanceof SVGElement ? J : I).bind(null, e, "Attribute"); let c = (e instanceof SVGElement ? J : I).bind(null, e, "Attribute");
@ -114,7 +114,7 @@ function O(e, ...t) {
case "xlink:href": case "xlink:href":
return c(s, d, "http://www.w3.org/1999/xlink"); return c(s, d, "http://www.w3.org/1999/xlink");
case "textContent": case "textContent":
return k(e, s, d); return M(e, s, d);
case "style": case "style":
if (typeof d != "object") if (typeof d != "object")
break; break;
@ -125,11 +125,11 @@ function O(e, ...t) {
case "classList": case "classList":
return B.call(n, e, d); return B.call(n, e, d);
} }
return G(e, s) ? k(e, s, d) : c(s, d); return G(e, s) ? M(e, s, d) : c(s, d);
}), e; }), e;
} }
function B(e, t) { function B(e, t) {
let n = _(this); let n = x(this);
return D( return D(
n, n,
t, t,
@ -157,14 +157,14 @@ function D(e, t, n) {
o && (c = e.processReactiveAttribute(t, o, c, (a) => n(...a)), n(o, c)); o && (c = e.processReactiveAttribute(t, o, c, (a) => n(...a)), n(o, c));
}); });
} }
function T(e) { function U(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e; return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
} }
function I(e, t, n, r) { function I(e, t, n, r) {
return e[(v(r) ? "remove" : "set") + t](n, T(r)); return e[(v(r) ? "remove" : "set") + t](n, U(r));
} }
function J(e, t, n, r, o = null) { function J(e, t, n, r, o = null) {
return e[(v(r) ? "remove" : "set") + t + "NS"](o, n, T(r)); return e[(v(r) ? "remove" : "set") + t + "NS"](o, n, U(r));
} }
function F(e, t, n) { function F(e, t, n) {
if (Reflect.set(e, t, n), !!v(n)) if (Reflect.set(e, t, n), !!v(n))
@ -176,31 +176,31 @@ function le(e, t, ...n) {
let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t); let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(r); return e.dispatchEvent(r);
} }
function x(e, t, n) { function S(e, t, n) {
return function(o) { return function(o) {
return o.addEventListener(e, t, n), o; return o.addEventListener(e, t, n), o;
}; };
} }
var R = Z(), V = /* @__PURE__ */ new WeakSet(); var R = Z(), V = /* @__PURE__ */ new WeakSet();
x.connected = function(e, t) { S.connected = function(e, t) {
let n = "connected"; let n = "connected";
return typeof t != "object" && (t = {}), t.once = !0, function(o) { return typeof t != "object" && (t = {}), t.once = !0, function(o) {
let c = "dde:" + n; let c = "dde:" + n;
return o.addEventListener(c, e, t), typeof o[n + "Callback"] == "function" ? o : o.isConnected ? (o.dispatchEvent(new Event(c)), o) : (A(t.signal, () => R.offConnected(o, e)) && R.onConnected(o, e), o); return o.addEventListener(c, e, t), o.__dde_lifecycleToEvents ? o : o.isConnected ? (o.dispatchEvent(new Event(c)), o) : (A(t.signal, () => R.offConnected(o, e)) && R.onConnected(o, e), o);
}; };
}; };
x.disconnected = function(e, t) { S.disconnected = function(e, t) {
let n = "disconnected"; let n = "disconnected";
return typeof t != "object" && (t = {}), t.once = !0, function(o) { return typeof t != "object" && (t = {}), t.once = !0, function(o) {
let c = "dde:" + n; let c = "dde:" + n;
return o.addEventListener(c, e, t), typeof o[n + "Callback"] == "function" || A(t.signal, () => R.offDisconnected(o, e)) && R.onDisconnected(o, e), o; return o.addEventListener(c, e, t), o.__dde_lifecycleToEvents || A(t.signal, () => R.offDisconnected(o, e)) && R.onDisconnected(o, e), o;
}; };
}; };
x.attributeChanged = function(e, t) { S.attributeChanged = function(e, t) {
let n = "attributeChanged"; let n = "attributeChanged";
return typeof t != "object" && (t = {}), function(o) { return typeof t != "object" && (t = {}), function(o) {
let c = "dde:" + n; let c = "dde:" + n;
if (o.addEventListener(c, e, t), typeof o[n + "Callback"] == "function" || V.has(o)) if (o.addEventListener(c, e, t), o.__dde_lifecycleToEvents || V.has(o))
return o; return o;
let a = new MutationObserver(function(d) { let a = new MutationObserver(function(d) {
for (let { attributeName: m, target: b } of d) for (let { attributeName: m, target: b } of d)
@ -285,8 +285,8 @@ function Z() {
for (let p of i) { for (let p of i) {
if (u && d(p).then(m), !e.has(p)) if (u && d(p).then(m), !e.has(p))
continue; continue;
let w = e.get(p); let _ = e.get(p);
w.length_c && (p.dispatchEvent(new Event("dde:connected")), w.connected = /* @__PURE__ */ new WeakSet(), w.length_c = 0, w.length_d || e.delete(p), f = !0); _.length_c && (p.dispatchEvent(new Event("dde:connected")), _.connected = /* @__PURE__ */ new WeakSet(), _.length_c = 0, _.length_d || e.delete(p), f = !0);
} }
return f; return f;
} }
@ -318,10 +318,10 @@ function C(e) {
var g = /* @__PURE__ */ new WeakMap(); var g = /* @__PURE__ */ new WeakMap();
function h(e, t) { function h(e, t) {
if (typeof e != "function") if (typeof e != "function")
return U(e, t); return $(e, t);
if (C(e)) if (C(e))
return e; return e;
let n = U(""), r = () => n(e()); let n = $(""), r = () => n(e());
return g.set(r, /* @__PURE__ */ new Set([n])), X(r), n; return g.set(r, /* @__PURE__ */ new Set([n])), X(r), n;
} }
h.action = function(e, t, ...n) { h.action = function(e, t, ...n) {
@ -337,7 +337,7 @@ h.on = function e(t, n, r = {}) {
if (!(o && o.aborted)) { if (!(o && o.aborted)) {
if (Array.isArray(t)) if (Array.isArray(t))
return t.forEach((c) => e(c, n, r)); return t.forEach((c) => e(c, n, r));
P(t, n), o && o.addEventListener("abort", () => q(t, n)); P(t, n), o && o.addEventListener("abort", () => H(t, n));
} }
}; };
h.symbols = { h.symbols = {
@ -350,7 +350,7 @@ h.attribute = function(e, t = void 0) {
o.abort(); o.abort();
} }
}); });
return E.host(x.attributeChanged(function({ detail: a }) { return E.host(S.attributeChanged(function({ detail: a }) {
let [s, d] = a; let [s, d] = a;
s === e && c(d); s === e && c(d);
}, { signal: o.signal })), c; }, { signal: o.signal })), c;
@ -375,7 +375,7 @@ h.el = function(e, t) {
o.append(n, r); o.append(n, r);
let c = (a) => { let c = (a) => {
if (!n.parentNode || !r.parentNode) if (!n.parentNode || !r.parentNode)
return q(e, c); return H(e, c);
let s = t(a); let s = t(a);
Array.isArray(s) || (s = [s]); Array.isArray(s) || (s = [s]);
let d = n; let d = n;
@ -385,13 +385,13 @@ h.el = function(e, t) {
}; };
return P(e, c), c(e()), o; return P(e, c), c(e()), o;
}; };
var $ = { var q = {
isSignal: C, isSignal: C,
processReactiveAttribute(e, t, n, r) { processReactiveAttribute(e, t, n, r) {
return C(n) ? (P(n, (o) => r([t, o])), n()) : n; return C(n) ? (P(n, (o) => r([t, o])), n()) : n;
} }
}; };
function U(e, t) { function $(e, t) {
let n = (...r) => r.length ? te(n, ...r) : ee(n); let n = (...r) => r.length ? te(n, ...r) : ee(n);
return Q(n, e, t); return Q(n, e, t);
} }
@ -434,13 +434,13 @@ function P(e, t) {
if (e[l]) if (e[l])
return e[l].listeners.add(t); return e[l].listeners.add(t);
} }
function q(e, t) { function H(e, t) {
if (e[l]) if (e[l])
return e[l].listeners.delete(t); return e[l].listeners.delete(t);
} }
// signals.js // signals.js
N($); N(q);
export { export {
h as S, h as S,
O as assign, O as assign,
@ -450,7 +450,7 @@ export {
ie as el, ie as el,
fe as empty, fe as empty,
C as isSignal, C as isSignal,
x as on, S as on,
N as registerReactivity, N as registerReactivity,
E as scope E as scope
}; };

90
dist/esm.js vendored
View File

@ -1,5 +1,5 @@
// src/signals-common.js // src/signals-common.js
var b = { var m = {
isSignal(e) { isSignal(e) {
return !1; return !1;
}, },
@ -8,17 +8,17 @@ var b = {
} }
}; };
function P(e, t = !0) { function P(e, t = !0) {
return t ? Object.assign(b, e) : (Object.setPrototypeOf(e, b), e); return t ? Object.assign(m, e) : (Object.setPrototypeOf(e, m), e);
} }
function E(e) { function b(e) {
return b.isPrototypeOf(e) && e !== b ? e : b; return m.isPrototypeOf(e) && e !== m ? e : m;
} }
// src/helpers.js // src/helpers.js
function g(e) { function g(e) {
return typeof e > "u"; return typeof e > "u";
} }
function w(e, t) { function _(e, t) {
if (!e || !(e instanceof AbortSignal)) if (!e || !(e instanceof AbortSignal))
return !0; return !0;
if (!e.aborted) if (!e.aborted)
@ -28,7 +28,7 @@ function w(e, t) {
} }
// src/dom-common.js // src/dom-common.js
var y = { setDeleteAttr: j }; var C = { setDeleteAttr: j };
function j(e, t, n) { function j(e, t, n) {
if (Reflect.set(e, t, n), !!g(n)) { if (Reflect.set(e, t, n), !!g(n)) {
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined") if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
@ -39,12 +39,12 @@ function j(e, t, n) {
} }
// src/dom.js // src/dom.js
var m = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.body) : document.body }], R = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, _ = { var E = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.body) : document.body }], R = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, x = {
get current() { get current() {
return m[m.length - 1]; return E[E.length - 1];
}, },
get state() { get state() {
return [...m]; return [...E];
}, },
get host() { get host() {
return this.current.host; return this.current.host;
@ -59,44 +59,44 @@ var m = [{ scope: document.body, namespace: "html", host: (e) => e ? e(document.
let t = this.namespace; let t = this.namespace;
return this.namespace = e, { return this.namespace = e, {
append(...n) { append(...n) {
return _.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n); return x.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
} }
}; };
}, },
push(e = {}) { push(e = {}) {
return e.namespace && (e.namespace = R(e.namespace)), m.push(Object.assign({}, this.current, e)); return e.namespace && (e.namespace = R(e.namespace)), E.push(Object.assign({}, this.current, e));
}, },
pop() { pop() {
return m.pop(); return E.pop();
} }
}; };
function V(e, t, ...n) { function V(e, t, ...n) {
let s = this, r = E(this), { namespace: f } = _, a; let s = this, r = b(this), { namespace: f } = x, a;
switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) { switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
_.push({ scope: e, host: (u) => u ? (n.unshift(u), void 0) : a }), a = e(t || void 0), _.pop(); x.push({ scope: e, host: (u) => u ? (n.unshift(u), void 0) : a }), a = e(t || void 0), x.pop();
break; break;
} }
case e === "#text": case e === "#text":
a = x.call(s, document.createTextNode(""), t); a = w.call(s, document.createTextNode(""), t);
break; break;
case e === "<>": case e === "<>":
a = x.call(s, document.createDocumentFragment(), t); a = w.call(s, document.createDocumentFragment(), t);
break; break;
case f !== "html": case f !== "html":
a = x.call(s, document.createElementNS(f, e), t); a = w.call(s, document.createElementNS(f, e), t);
break; break;
case !a: case !a:
a = x.call(s, document.createElement(e), t); a = w.call(s, document.createElement(e), t);
} }
return n.forEach((u) => u(a)), a; return n.forEach((u) => u(a)), a;
} }
var { setDeleteAttr: S } = y; var { setDeleteAttr: S } = C;
function x(e, ...t) { function w(e, ...t) {
let n = this, s = E(this); let n = this, s = b(this);
if (!t.length) if (!t.length)
return e; return e;
let f = (e instanceof SVGElement ? T : F).bind(null, e, "Attribute"); let f = (e instanceof SVGElement ? F : W).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function a([u, d]) { return Object.entries(Object.assign({}, ...t)).forEach(function a([u, d]) {
d = s.processReactiveAttribute(e, u, d, a); d = s.processReactiveAttribute(e, u, d, a);
let [h] = u; let [h] = u;
@ -115,18 +115,18 @@ function x(e, ...t) {
if (typeof d != "object") if (typeof d != "object")
break; break;
case "dataset": case "dataset":
return C(s, d, L.bind(null, e[u])); return O(s, d, L.bind(null, e[u]));
case "ariaset": case "ariaset":
return C(s, d, (l, c) => f("aria-" + l, c)); return O(s, d, (l, c) => f("aria-" + l, c));
case "classList": case "classList":
return M.call(n, e, d); return T.call(n, e, d);
} }
return W(e, u) ? S(e, u, d) : f(u, d); return M(e, u) ? S(e, u, d) : f(u, d);
}), e; }), e;
} }
function M(e, t) { function T(e, t) {
let n = E(this); let n = b(this);
return C( return O(
n, n,
t, t,
(s, r) => e.classList.toggle(s, r === -1 ? void 0 : !!r) (s, r) => e.classList.toggle(s, r === -1 ? void 0 : !!r)
@ -135,7 +135,7 @@ function M(e, t) {
function $(e) { function $(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function W(e, t) { function M(e, t) {
if (!Reflect.has(e, t)) if (!Reflect.has(e, t))
return !1; return !1;
let n = D(e, t); let n = D(e, t);
@ -147,7 +147,7 @@ function D(e, t) {
let n = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return n || D(e, t); return n || D(e, t);
} }
function C(e, t, n) { function O(e, t, n) {
if (!(typeof t != "object" || t === null)) if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([r, f]) { return Object.entries(t).forEach(function([r, f]) {
r && (f = e.processReactiveAttribute(t, r, f, (a) => n(...a)), n(r, f)); r && (f = e.processReactiveAttribute(t, r, f, (a) => n(...a)), n(r, f));
@ -156,10 +156,10 @@ function C(e, t, n) {
function N(e) { function N(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e; return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
} }
function F(e, t, n, s) { function W(e, t, n, s) {
return e[(g(s) ? "remove" : "set") + t](n, N(s)); return e[(g(s) ? "remove" : "set") + t](n, N(s));
} }
function T(e, t, n, s, r = null) { function F(e, t, n, s, r = null) {
return e[(g(s) ? "remove" : "set") + t + "NS"](r, n, N(s)); return e[(g(s) ? "remove" : "set") + t + "NS"](r, n, N(s));
} }
function L(e, t, n) { function L(e, t, n) {
@ -172,31 +172,31 @@ function Q(e, t, ...n) {
let s = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t); let s = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(s); return e.dispatchEvent(s);
} }
function O(e, t, n) { function y(e, t, n) {
return function(r) { return function(r) {
return r.addEventListener(e, t, n), r; return r.addEventListener(e, t, n), r;
}; };
} }
var A = q(), U = /* @__PURE__ */ new WeakSet(); var A = q(), U = /* @__PURE__ */ new WeakSet();
O.connected = function(e, t) { y.connected = function(e, t) {
let n = "connected"; let n = "connected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) { return typeof t != "object" && (t = {}), t.once = !0, function(r) {
let f = "dde:" + n; let f = "dde:" + n;
return r.addEventListener(f, e, t), typeof r[n + "Callback"] == "function" ? r : r.isConnected ? (r.dispatchEvent(new Event(f)), r) : (w(t.signal, () => A.offConnected(r, e)) && A.onConnected(r, e), r); return r.addEventListener(f, e, t), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(f)), r) : (_(t.signal, () => A.offConnected(r, e)) && A.onConnected(r, e), r);
}; };
}; };
O.disconnected = function(e, t) { y.disconnected = function(e, t) {
let n = "disconnected"; let n = "disconnected";
return typeof t != "object" && (t = {}), t.once = !0, function(r) { return typeof t != "object" && (t = {}), t.once = !0, function(r) {
let f = "dde:" + n; let f = "dde:" + n;
return r.addEventListener(f, e, t), typeof r[n + "Callback"] == "function" || w(t.signal, () => A.offDisconnected(r, e)) && A.onDisconnected(r, e), r; return r.addEventListener(f, e, t), r.__dde_lifecycleToEvents || _(t.signal, () => A.offDisconnected(r, e)) && A.onDisconnected(r, e), r;
}; };
}; };
O.attributeChanged = function(e, t) { y.attributeChanged = function(e, t) {
let n = "attributeChanged"; let n = "attributeChanged";
return typeof t != "object" && (t = {}), function(r) { return typeof t != "object" && (t = {}), function(r) {
let f = "dde:" + n; let f = "dde:" + n;
if (r.addEventListener(f, e, t), typeof r[n + "Callback"] == "function" || U.has(r)) if (r.addEventListener(f, e, t), r.__dde_lifecycleToEvents || U.has(r))
return r; return r;
let a = new MutationObserver(function(d) { let a = new MutationObserver(function(d) {
for (let { attributeName: h, target: l } of d) for (let { attributeName: h, target: l } of d)
@ -204,7 +204,7 @@ O.attributeChanged = function(e, t) {
new CustomEvent(f, { detail: [h, l.getAttribute(h)] }) new CustomEvent(f, { detail: [h, l.getAttribute(h)] })
); );
}); });
return w(t.signal, () => a.disconnect()) && a.observe(r, { attributes: !0 }), r; return _(t.signal, () => a.disconnect()) && a.observe(r, { attributes: !0 }), r;
}; };
}; };
function q() { function q() {
@ -302,13 +302,13 @@ function q() {
}; };
}); });
export { export {
x as assign, w as assign,
M as classListDeclarative, T as classListDeclarative,
V as createElement, V as createElement,
Q as dispatchEvent, Q as dispatchEvent,
V as el, V as el,
$ as empty, $ as empty,
O as on, y as on,
P as registerReactivity, P as registerReactivity,
_ as scope x as scope
}; };

View File

@ -74,6 +74,7 @@ function lifecycleToEvents(class_declaration){
})); }));
target.apply(thisArg, detail); target.apply(thisArg, detail);
}); });
class_declaration.prototype.__dde_lifecycleToEvents= true;
} }
function wrapMethod(obj, method, apply){ function wrapMethod(obj, method, apply){
obj[method]= new Proxy(obj[method] || (()=> {}), { apply }); obj[method]= new Proxy(obj[method] || (()=> {}), { apply });

View File

@ -23,11 +23,8 @@ on.connected= function(listener, options){
return function registerElement(element){ return function registerElement(element){
const event= "dde:"+name; const event= "dde:"+name;
element.addEventListener(event, listener, options); element.addEventListener(event, listener, options);
if(typeof element[name+"Callback"] === "function") return element; if(element.__dde_lifecycleToEvents) return element;
if(element.isConnected){ if(element.isConnected) return ( element.dispatchEvent(new Event(event)), element )
element.dispatchEvent(new Event(event));
return element;
}
const c= onAbort(options.signal, ()=> c_ch_o.offConnected(element, listener)); const c= onAbort(options.signal, ()=> c_ch_o.offConnected(element, listener));
if(c) c_ch_o.onConnected(element, listener); if(c) c_ch_o.onConnected(element, listener);
@ -42,7 +39,7 @@ on.disconnected= function(listener, options){
return function registerElement(element){ return function registerElement(element){
const event= "dde:"+name; const event= "dde:"+name;
element.addEventListener(event, listener, options); element.addEventListener(event, listener, options);
if(typeof element[name+"Callback"] === "function") return element; if(element.__dde_lifecycleToEvents) return element;
const c= onAbort(options.signal, ()=> c_ch_o.offDisconnected(element, listener)); const c= onAbort(options.signal, ()=> c_ch_o.offDisconnected(element, listener));
if(c) c_ch_o.onDisconnected(element, listener); if(c) c_ch_o.onDisconnected(element, listener);
@ -56,8 +53,8 @@ on.attributeChanged= function(listener, options){
return function registerElement(element){ return function registerElement(element){
const event= "dde:"+name; const event= "dde:"+name;
element.addEventListener(event, listener, options); element.addEventListener(event, listener, options);
if(typeof element[name+"Callback"] === "function") return element; if(element.__dde_lifecycleToEvents || els_attribute_store.has(element))
if(els_attribute_store.has(element)) return element; return element;
const observer= new MutationObserver(function(mutations){ const observer= new MutationObserver(function(mutations){
for(const { attributeName, target } of mutations) for(const { attributeName, target } of mutations)