diff --git a/dist/dde-with-signals.js b/dist/dde-with-signals.js index 4c26f47..38bb13a 100644 --- a/dist/dde-with-signals.js +++ b/dist/dde-with-signals.js @@ -43,8 +43,8 @@ var S = "html"; function oe(e) { return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, { - append(t) { - return S = "html", t; + append(...t) { + return S = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t); } }; } @@ -266,10 +266,10 @@ var l = /* @__PURE__ */ new WeakMap(); function g(e, t) { if (typeof e != "function") - return z(e, t); + return F(e, t); if (L(e)) return e; - let r = z(""), n = () => r(e()); + let r = F(""), n = () => r(e()); return l.set(n, /* @__PURE__ */ new Set([r])), G(n), r; } g.action = function(e, t, ...r) { @@ -322,7 +322,7 @@ }; return P(e, a), a(e()), o; }; - var F = { + var z = { isTextContent(e) { return w(e) === "string" || L(e) && w(X(e)) === "string"; }, @@ -330,7 +330,7 @@ return L(r) ? (P(r, (o) => n([t, o])), r()) : r; } }; - function z(e, t) { + function F(e, t) { let r = (...n) => n.length ? Q(r, n[0]) : K(r); return B(r, e, t); } @@ -381,8 +381,8 @@ return e[d].listeners.delete(t); } - // src/signals.js - _(F); + // signals.js + _(z); globalThis.dde= { S: g, diff --git a/dist/dde.js b/dist/dde.js index f9d493e..1a06edc 100644 --- a/dist/dde.js +++ b/dist/dde.js @@ -36,11 +36,11 @@ } // src/dom.js - var m = "html"; + var v = "html"; function I(e) { - return m = e === "svg" ? "http://www.w3.org/2000/svg" : e, { - append(t) { - return m = "html", t; + return v = e === "svg" ? "http://www.w3.org/2000/svg" : e, { + append(...t) { + return v = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t); } }; } @@ -57,8 +57,8 @@ case e === "<>": c = E(document.createDocumentFragment(), t); break; - case m !== "html": - c = E(document.createElementNS(m, e), t); + case v !== "html": + c = E(document.createElementNS(v, e), t); break; case !c: c = E(document.createElement(e), t); @@ -81,11 +81,11 @@ if (typeof f == "object") switch (s) { case "style": - return v(f, N.bind(null, e.style, "Property")); + return m(f, N.bind(null, e.style, "Property")); case "dataset": - return v(f, y.bind(null, e.dataset)); + return m(f, y.bind(null, e.dataset)); case "ariaset": - return v(f, (x, b) => c("aria-" + x, b)); + return m(f, (x, b) => c("aria-" + x, b)); case "classList": return j(e, f); default: @@ -107,7 +107,7 @@ }), e; } function j(e, t) { - return typeof t != "object" || v( + return typeof t != "object" || m( t, (r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n) ), e; @@ -122,16 +122,16 @@ let n = e.nodeName + "," + t; if (h.has(n)) return h.get(n); - let [c, a, s] = _(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; } - function _(e, t, r = 0) { + function D(e, t, r = 0) { if (e = Object.getPrototypeOf(e), !e) return [{}, r, e]; let n = Object.getOwnPropertyDescriptor(e, t); - return n ? [n, r, e] : _(e, t, r + 1); + return n ? [n, r, e] : D(e, t, r + 1); } - function v(e, t) { + function m(e, t) { return Object.entries(e).forEach(([r, n]) => t(r, n)); } function N(e, t, r, n) { @@ -146,18 +146,18 @@ let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t); return e.dispatchEvent(n); } - function D(e, t, r) { + function _(e, t, r) { return function(c) { return c.addEventListener(e, t, r), c; }; } var w = P(); - D.connected = function(e, t) { + _.connected = function(e, t) { 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); }; }; - D.disconnected = function(e, t) { + _.disconnected = function(e, t) { 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); }; @@ -258,7 +258,7 @@ el: Z, empty: B, namespace: I, - on: D, + on: _, registerReactivity: T }; diff --git a/dist/esm-with-signals.js b/dist/esm-with-signals.js index a8ad445..570f84e 100644 --- a/dist/esm-with-signals.js +++ b/dist/esm-with-signals.js @@ -41,8 +41,8 @@ function $(e, t, r) { var S = "html"; function oe(e) { return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, { - append(t) { - return S = "html", t; + append(...t) { + return S = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t); } }; } @@ -264,10 +264,10 @@ function L(e) { var l = /* @__PURE__ */ new WeakMap(); function g(e, t) { if (typeof e != "function") - return z(e, t); + return F(e, t); if (L(e)) return e; - let r = z(""), n = () => r(e()); + let r = F(""), n = () => r(e()); return l.set(n, /* @__PURE__ */ new Set([r])), G(n), r; } g.action = function(e, t, ...r) { @@ -320,7 +320,7 @@ g.el = function(e, t) { }; return P(e, a), a(e()), o; }; -var F = { +var z = { isTextContent(e) { return w(e) === "string" || L(e) && w(X(e)) === "string"; }, @@ -328,7 +328,7 @@ var F = { return L(r) ? (P(r, (o) => n([t, o])), r()) : r; } }; -function z(e, t) { +function F(e, t) { let r = (...n) => n.length ? Q(r, n[0]) : K(r); return B(r, e, t); } @@ -379,8 +379,8 @@ function U(e, t) { return e[d].listeners.delete(t); } -// src/signals.js -_(F); +// signals.js +_(z); export { g as S, y as assign, diff --git a/dist/esm.js b/dist/esm.js index 213680e..0857c02 100644 --- a/dist/esm.js +++ b/dist/esm.js @@ -34,11 +34,11 @@ function R(e, t, r) { } // src/dom.js -var m = "html"; +var v = "html"; function I(e) { - return m = e === "svg" ? "http://www.w3.org/2000/svg" : e, { - append(t) { - return m = "html", t; + return v = e === "svg" ? "http://www.w3.org/2000/svg" : e, { + append(...t) { + return v = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t); } }; } @@ -55,8 +55,8 @@ function Z(e, t, ...r) { case e === "<>": c = E(document.createDocumentFragment(), t); break; - case m !== "html": - c = E(document.createElementNS(m, e), t); + case v !== "html": + c = E(document.createElementNS(v, e), t); break; case !c: c = E(document.createElement(e), t); @@ -79,11 +79,11 @@ function E(e, ...t) { if (typeof f == "object") switch (s) { case "style": - return v(f, N.bind(null, e.style, "Property")); + return m(f, N.bind(null, e.style, "Property")); case "dataset": - return v(f, y.bind(null, e.dataset)); + return m(f, y.bind(null, e.dataset)); case "ariaset": - return v(f, (x, b) => c("aria-" + x, b)); + return m(f, (x, b) => c("aria-" + x, b)); case "classList": return j(e, f); default: @@ -105,7 +105,7 @@ function E(e, ...t) { }), e; } function j(e, t) { - return typeof t != "object" || v( + return typeof t != "object" || m( t, (r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n) ), e; @@ -120,16 +120,16 @@ function M(e, t) { let n = e.nodeName + "," + t; if (h.has(n)) return h.get(n); - let [c, a, s] = _(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; } -function _(e, t, r = 0) { +function D(e, t, r = 0) { if (e = Object.getPrototypeOf(e), !e) return [{}, r, e]; let n = Object.getOwnPropertyDescriptor(e, t); - return n ? [n, r, e] : _(e, t, r + 1); + return n ? [n, r, e] : D(e, t, r + 1); } -function v(e, t) { +function m(e, t) { return Object.entries(e).forEach(([r, n]) => t(r, n)); } function N(e, t, r, n) { @@ -144,18 +144,18 @@ function V(e, t, ...r) { let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t); return e.dispatchEvent(n); } -function D(e, t, r) { +function _(e, t, r) { return function(c) { return c.addEventListener(e, t, r), c; }; } var w = P(); -D.connected = function(e, t) { +_.connected = function(e, t) { 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); }; }; -D.disconnected = function(e, t) { +_.disconnected = function(e, t) { 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); }; @@ -255,6 +255,6 @@ export { Z as el, B as empty, I as namespace, - D as on, + _ as on, T as registerReactivity }; diff --git a/index-with-signals.js b/index-with-signals.js index 12cccf7..e969ab0 100644 --- a/index-with-signals.js +++ b/index-with-signals.js @@ -1,2 +1,2 @@ export * from "./index.js"; -export * from "./src/signals.js"; +export * from "./signals.js"; diff --git a/package.json b/package.json index 8f8bde2..91a508f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deka-dom-el", - "version": "0.2.0", + "version": "0.2.1", "description": "A low-code library that simplifies the creation of native DOM elements/components using small wrappers and tweaks.", "author": "Jan Andrle ", "license": "MIT", diff --git a/signals.js b/signals.js index 4ea6575..c28bcca 100644 --- a/signals.js +++ b/signals.js @@ -1,4 +1,4 @@ -export { S, isSignal } from "src/signals-lib.js"; -import { signals_config } from "src/signals-lib.js"; -import { registerReactivity } from "src/signals-common.js"; +export { S, isSignal } from "./src/signals-lib.js"; +import { signals_config } from "./src/signals-lib.js"; +import { registerReactivity } from "./src/signals-common.js"; registerReactivity(signals_config); diff --git a/src/dom.js b/src/dom.js index 888abf6..4e4eee2 100644 --- a/src/dom.js +++ b/src/dom.js @@ -5,7 +5,12 @@ let namespace_curr= "html"; export function namespace(namespace){ namespace_curr= namespace==="svg" ? "http://www.w3.org/2000/svg" : namespace; return { - append(el){ namespace_curr= "html"; return el; } + append(...el){ + namespace_curr= "html"; + if(el.length===1) return el[0]; + const f= document.createDocumentFragment(); + return f.append(...el); + } }; } export function createElement(tag, attributes, ...connect){ diff --git a/test/components/webComponent.js b/test/components/webComponent.js index d12fe8d..63bff49 100644 --- a/test/components/webComponent.js +++ b/test/components/webComponent.js @@ -1,5 +1,5 @@ import { el } from "../../index.js"; -import { S } from "../../src/signals.js"; +import { S } from "../../signals.js"; const { hasOwnProperty }= Object.prototype; const store= attrsPropsToSignals([ "test" ]);