aboutsummaryrefslogtreecommitdiff
path: root/src/zilch/component.template.js
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-26 09:23:55 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-26 09:23:55 +0100
commit91d9b6992ac0ebee13704a3faefa8fd41a00075e (patch)
treeea0a30cc0cfb2232d3e60c845c20a67b6cdf0b99 /src/zilch/component.template.js
parent65300a13dcd11037218bf8ba61efd8ca19e5920e (diff)
zilch: dynamic element creation
Diffstat (limited to 'src/zilch/component.template.js')
-rw-r--r--src/zilch/component.template.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/zilch/component.template.js b/src/zilch/component.template.js
index e8cb914..6addef2 100644
--- a/src/zilch/component.template.js
+++ b/src/zilch/component.template.js
@@ -8,14 +8,12 @@ customElements.define("{s}-{s}", class extends HTMLElement {{
this[ZsPtr] = null;
}}
connectedCallback() {{
- wasm_ready.then(() => {{
- const id = ObjectStore.generateFreeId();
- ObjectStore.registerObject(id, this);
- this[ZsPtr] = wasm.exports['export::{s}::init'](id);
- }});
+ if (this[ZsPtr] === null) {{
+ wasm_ready.then(() => {{
+ const id = ObjectStore.generateFreeId();
+ ObjectStore.registerObject(id, this);
+ this[ZsPtr] = wasm.exports['export::{s}::init'](id, this[ZsPtr]);
+ }});
+ }}
}}
- disconnectedCallback() {{
- wasm.exports['export::{s}::deinit'](this[ZsId]);
- ObjectStore.free(this);
- }}
-}})
+}});