@adia-ai/web-components 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/element.js +12 -2
- package/core/template.js +2 -11
- package/package.json +1 -1
package/core/element.js
CHANGED
|
@@ -17,7 +17,7 @@ export { signal, computed, effect, batch, untracked, isSignal } from './signals.
|
|
|
17
17
|
export { html, css, repeat } from './template.js';
|
|
18
18
|
|
|
19
19
|
// Internal imports for AdiaElement
|
|
20
|
-
import { signal, computed, effect } from './signals.js';
|
|
20
|
+
import { signal, computed, effect, untracked } from './signals.js';
|
|
21
21
|
import { stamp, disposeParts, KEY_MAP } from './template.js';
|
|
22
22
|
|
|
23
23
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -105,7 +105,17 @@ export class AdiaElement extends HTMLElement {
|
|
|
105
105
|
if (!ctor._tag) ctor._tag = this.localName;
|
|
106
106
|
adoptStyles(ctor);
|
|
107
107
|
prepareParts(ctor);
|
|
108
|
-
|
|
108
|
+
// connected() commonly reads this element's reactive properties via
|
|
109
|
+
// template-literal interpolation (`${this.label}` etc.) to stamp its
|
|
110
|
+
// inner DOM. If the outer call path is inside another effect (e.g.
|
|
111
|
+
// a parent's render loop appendChild'ing this node), those reads
|
|
112
|
+
// would subscribe the outer effect to THIS element's signals —
|
|
113
|
+
// invisible cross-element coupling that looks like spooky re-runs
|
|
114
|
+
// on unrelated state changes. Wrap in untracked so element setup
|
|
115
|
+
// never leaks subscriptions upward. The element's OWN effect
|
|
116
|
+
// (below) re-reads the same signals in its own tracking context,
|
|
117
|
+
// so reactivity within the element is unaffected.
|
|
118
|
+
untracked(() => this.connected());
|
|
109
119
|
this.#fx.push(effect(() => {
|
|
110
120
|
for (const sig of this[SIG].values()) sig.value;
|
|
111
121
|
this.#notify.value;
|
package/core/template.js
CHANGED
|
@@ -68,21 +68,12 @@ export function stamp(result, container) {
|
|
|
68
68
|
update(inst.p, result.values);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// Safari 14.0 lacks ChildNode.replaceChildren. Fallback manually removes
|
|
72
|
-
// existing children, then appends the new content. Runs once per call;
|
|
73
|
-
// cheap enough to be unconditional.
|
|
74
|
-
function replaceChildren(container, ...nodes) {
|
|
75
|
-
if (container.replaceChildren) { container.replaceChildren(...nodes); return; }
|
|
76
|
-
while (container.firstChild) container.removeChild(container.firstChild);
|
|
77
|
-
for (const n of nodes) container.appendChild(n);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
71
|
function mount(result, container) {
|
|
81
72
|
const { strings } = result;
|
|
82
73
|
const tpl = getTemplate(strings);
|
|
83
74
|
const f = tpl.content.cloneNode(true);
|
|
84
75
|
const parts = scan(f, result.values.length);
|
|
85
|
-
replaceChildren(
|
|
76
|
+
container.replaceChildren(f);
|
|
86
77
|
return { s: strings, p: parts };
|
|
87
78
|
}
|
|
88
79
|
|
|
@@ -147,7 +138,7 @@ function applyValue(p, v) {
|
|
|
147
138
|
stamp(v, wrap(p));
|
|
148
139
|
} else if (Array.isArray(v)) {
|
|
149
140
|
const c = wrap(p);
|
|
150
|
-
replaceChildren(
|
|
141
|
+
c.replaceChildren();
|
|
151
142
|
for (const item of v) {
|
|
152
143
|
if (isResult(item)) {
|
|
153
144
|
const el = document.createElement('span');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adia-ai/web-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "AdiaUI web components — vanilla custom elements. A2UI runtime (renderer, registry, streams, wiring) lives in @adia-ai/a2ui-utils.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|