From c8744f9f6a28a23b83603435a3ad987f0d9f181b Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 30 Jul 2026 07:46:37 +0200 Subject: temporal commit --- src/z/z.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/z/z.js') diff --git a/src/z/z.js b/src/z/z.js index ba07b9e..e279f42 100644 --- a/src/z/z.js +++ b/src/z/z.js @@ -1,10 +1,14 @@ class ZComponent extends HTMLElement { + static observedAttributes = [ 'type' ]; + constructor() { super(); this.attachShadow({ mode: 'open' }); + this.onconnected = () => {}; + this.ondisconnected = () => {}; } - connectedCallback() { + build() { const type = this.getAttribute('type'); if (type == null) { @@ -22,6 +26,21 @@ class ZComponent extends HTMLElement { Zenv.constructors[`component__${type}`](new Zenv(this)); } + + attributeChangedCallback(name, previous, current) { + if (name == 'type') { + this.shadowRoot.innerHTML = ''; + this.build() + } + } + + connectedCallback() { + this.onconnected(); + } + + disconnectedCallback() { + this.ondisconnected(); + } } class Zenv { -- cgit v1.2.3-70-g09d2