mirror of
https://github.com/jaandrle/deka-dom-el
synced 2025-04-02 20:15:53 +02:00
* :tap: removed on.attributeChanged and static observedAttributes * ⚡ import optimalization * ⚡ scope.signal * 🔤 🐛 * ⚡ 🐛 registerReactivity and types * 🔤 * ⚡ * 🔤 * 🐛 Node in enviroment * ⚡ todos * ⚡ * ⚡ 🔤 * ⚡ lint * ⚡ memo * 🔤 🐛 memo * ⚡ 🔤 todomvc * 🐛 types * 🔤 p08 signal factory * 🔤 ⚡ types * ⚡ 🔤 lint * 🔤 * 🔤 * 🔤 * 🔤 * 📺
34 lines
856 B
JavaScript
34 lines
856 B
JavaScript
import {
|
|
customElementRender,
|
|
customElementWithDDE,
|
|
} from "deka-dom-el";
|
|
export class HTMLCustomElement extends HTMLElement{
|
|
static tagName= "custom-element";
|
|
static observedAttributes= [ "attr" ];
|
|
connectedCallback(){
|
|
customElementRender(
|
|
this.attachShadow({ mode: "open" }),
|
|
ddeComponent,
|
|
this
|
|
);
|
|
}
|
|
set attr(value){ this.setAttribute("attr", value); }
|
|
get attr(){ return this.getAttribute("attr"); }
|
|
}
|
|
|
|
import { el, on, scope } from "deka-dom-el";
|
|
function ddeComponent({ attr }){
|
|
scope.host(
|
|
on.connected(e=> console.log(e.target.outerHTML)),
|
|
);
|
|
return el().append(
|
|
el("p", `Hello from Custom Element with attribute '${attr}'`)
|
|
);
|
|
}
|
|
customElementWithDDE(HTMLCustomElement);
|
|
customElements.define(HTMLCustomElement.tagName, HTMLCustomElement);
|
|
|
|
document.body.append(
|
|
el(HTMLCustomElement.tagName, { attr: "Attribute" })
|
|
);
|