diff --git a/docs/p06-customElement.html b/docs/p06-customElement.html index e7b295d..af281da 100644 --- a/docs/p06-customElement.html +++ b/docs/p06-customElement.html @@ -44,11 +44,17 @@ customElementWithDDE(HTMLCustomElement); customElements.define(HTMLCustomElement.tagName, HTMLCustomElement); const instance= el(HTMLCustomElement.tagName); -on.connected(e=> console.log("Element connected to the DOM:", e))(instance); +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) +); document.body.append( instance, ); -
import {
+
The customElementWithDDE
function is only (small) part of the inregration of the library. More important for coexistence is render component function as a body of the Custom Element.
import {
customElementRender,
customElementWithDDE,
} from "./esm-with-signals.js";
@@ -69,7 +75,7 @@ export class HTMLCustomElement extends HTMLElement{
import { el, on, scope } from "./esm-with-signals.js";
function ddeComponent({ attr }){
scope.host(
- on.connected(e=> console.log(this.outerHTML)),
+ on.connected(e=> console.log(e.target.outerHTML)),
);
return el().append(
el("p", `Hello from Custom Element with attribute '${attr}'`)
@@ -81,4 +87,4 @@ customElements.define(HTMLCustomElement.tagName, HTMLCustomElement);
document.body.append(
el(HTMLCustomElement.tagName, { attr: "Attribute" })
);
-
customElementRender(<custom-element>, <render-function>[, <properties>])
— use function to render DOM structure for given <custom-element>customElementWithDDE(<custom-element>)
— register <custom-element> to DDE library, see also `lifecyclesToEvents`, can be also used as decoratorobservedAttributes(<custom-element>)
— returns record of observed attributes (keys uses camelCase)S.observedAttributes(<custom-element>)
— returns record of observed attributes (keys uses camelCase and values are signals)lifecyclesToEvents(<class-declaration>)
— convert lifecycle methods to events, can be also used as decorator