2024-06-05 16:20:12 +02:00
|
|
|
import { customElementWithDDE, el, on } from "deka-dom-el";
|
|
|
|
export class HTMLCustomElement extends HTMLElement{
|
|
|
|
static tagName= "custom-element";
|
|
|
|
connectedCallback(){
|
|
|
|
this.append(
|
|
|
|
el("p", "Hello from custom element!")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
customElementWithDDE(HTMLCustomElement);
|
|
|
|
customElements.define(HTMLCustomElement.tagName, HTMLCustomElement);
|
|
|
|
|
|
|
|
const instance= el(HTMLCustomElement.tagName);
|
2024-06-07 10:04:34 +02:00
|
|
|
on.connected( // preffered
|
|
|
|
e=> console.log("Element connected to the DOM (v1):", e)
|
|
|
|
)(instance);
|
|
|
|
instance.addEventListener(
|
|
|
|
"dde:connected",
|
|
|
|
e=> console.log("Element connected to the DOM (v2):", e)
|
|
|
|
);
|
2024-06-05 16:20:12 +02:00
|
|
|
document.body.append(
|
|
|
|
instance,
|
|
|
|
);
|