1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-07-29 07:00:16 +02:00

♻️ Update scope and namespace handling (scope hook)

This commit is contained in:
2023-10-10 10:55:00 +02:00
parent ebbb76e9a0
commit 6a52972373
8 changed files with 693 additions and 619 deletions

View File

@@ -1,4 +1,4 @@
import { el } from "../../index.js";
import { el, scope } from "../../index.js";
import { S } from "../../signals.js";
const { hasOwnProperty }= Object.prototype;
@@ -16,9 +16,10 @@ export class CustomHTMLTestElement extends HTMLElement{
);
}
render({ name, test, preName }, host){
host(on.connected(()=> console.log(CustomHTMLTestElement)));
host(on.disconnected(()=> console.log(CustomHTMLTestElement)));
render({ name, test, preName }){
console.log(scope.state);
scope.host(on.connected(()=> console.log(CustomHTMLTestElement)));
scope.host(on.disconnected(()=> console.log(CustomHTMLTestElement)));
return el("p").append(
el("#text", { textContent: name }),
el("#text", { textContent: test }),
@@ -36,8 +37,10 @@ customElementsAssign(
customElements.define("custom-test", CustomHTMLTestElement);
function customElementRender(_this, attrs, render){
const host= (...a)=> a.length ? a[0](_this) : _this;
return render(attrs, host);
scope.push({ scope: _this, host: (...a)=> a.length ? a[0](_this) : _this });
const out= render(attrs);
scope.pop();
return out;
}
/** @returns {HTMLElement} */
function customElementsAssign(class_base, ...automatize){