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

♻️ 🔨 🐛 e.g. better namespace #18

This commit is contained in:
Jan Andrle 2023-09-19 09:30:21 +02:00
parent 9c5ac96ab8
commit 1df797e316
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
9 changed files with 64 additions and 59 deletions

View File

@ -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,

36
dist/dde.js vendored
View File

@ -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
};

View File

@ -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,

36
dist/esm.js vendored
View File

@ -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
};

View File

@ -1,2 +1,2 @@
export * from "./index.js";
export * from "./src/signals.js";
export * from "./signals.js";

View File

@ -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 <andrle.jan@centrum.cz>",
"license": "MIT",

View File

@ -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);

View File

@ -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){

View File

@ -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" ]);