diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-07-30 07:46:37 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-07-30 07:46:37 +0200 |
| commit | c8744f9f6a28a23b83603435a3ad987f0d9f181b (patch) | |
| tree | e0257c54661e9f34b6d2ce8658346f36aa0ff9e3 /src/z/z.js | |
| parent | d1776161dcc57b600ce7b18c5e7179757491fbc2 (diff) | |
temporal commit
Diffstat (limited to 'src/z/z.js')
| -rw-r--r-- | src/z/z.js | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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 { |