@sprlab/wccompiler 0.5.8 → 0.5.9
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/lib/codegen.js +12 -2
- package/package.json +1 -1
package/lib/codegen.js
CHANGED
|
@@ -1000,6 +1000,7 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
1000
1000
|
lines.push(' const clone = tpl.content.cloneNode(true);');
|
|
1001
1001
|
lines.push(' const node = clone.firstChild;');
|
|
1002
1002
|
lines.push(` this.${vn}_anchor.parentNode.insertBefore(node, this.${vn}_anchor);`);
|
|
1003
|
+
lines.push(' customElements.upgrade(node);');
|
|
1003
1004
|
lines.push(` this.${vn}_current = node;`);
|
|
1004
1005
|
// Setup bindings/events for active branch (only if any branch has bindings/events)
|
|
1005
1006
|
const hasSetup = ifBlock.branches.some(b =>
|
|
@@ -1066,7 +1067,7 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
1066
1067
|
lines.push(' for (const n of __oldMap.values()) n.remove();');
|
|
1067
1068
|
lines.push('');
|
|
1068
1069
|
lines.push(' // Reorder: insert all nodes in correct order before anchor');
|
|
1069
|
-
lines.push(` for (const n of __newNodes) this.${vn}_anchor.parentNode.insertBefore(n, this.${vn}_anchor)
|
|
1070
|
+
lines.push(` for (const n of __newNodes) { this.${vn}_anchor.parentNode.insertBefore(n, this.${vn}_anchor); customElements.upgrade(n); }`);
|
|
1070
1071
|
lines.push('');
|
|
1071
1072
|
lines.push(` this.${vn}_nodes = __newNodes;`);
|
|
1072
1073
|
lines.push(` this.${vn}_keyMap = __newMap;`);
|
|
@@ -1083,6 +1084,7 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
1083
1084
|
generateItemSetup(lines, forBlock, itemVar, indexVar, propNames, signalNamesSet, computedNamesSet);
|
|
1084
1085
|
|
|
1085
1086
|
lines.push(` this.${vn}_anchor.parentNode.insertBefore(node, this.${vn}_anchor);`);
|
|
1087
|
+
lines.push(' customElements.upgrade(node);');
|
|
1086
1088
|
lines.push(` this.${vn}_nodes.push(node);`);
|
|
1087
1089
|
lines.push(' });');
|
|
1088
1090
|
lines.push(' }));');
|
|
@@ -1254,7 +1256,15 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
1254
1256
|
} else if (b.type === 'computed') {
|
|
1255
1257
|
lines.push(` __effect(() => { ${b.varName}.textContent = this._c_${b.name}() ?? ''; });`);
|
|
1256
1258
|
} else {
|
|
1257
|
-
|
|
1259
|
+
// method/expression type — check for props.x pattern
|
|
1260
|
+
let ref;
|
|
1261
|
+
if (propsObjectName && b.name.startsWith(propsObjectName + '.')) {
|
|
1262
|
+
const propName = b.name.slice(propsObjectName.length + 1);
|
|
1263
|
+
ref = `this._s_${propName}()`;
|
|
1264
|
+
} else {
|
|
1265
|
+
ref = transformExpr(b.name, signalNames, computedNames, propsObjectName, propNames, emitsObjectName, constantNames, methodNames);
|
|
1266
|
+
}
|
|
1267
|
+
lines.push(` __effect(() => { ${b.varName}.textContent = ${ref} ?? ''; });`);
|
|
1258
1268
|
}
|
|
1259
1269
|
}
|
|
1260
1270
|
|
package/package.json
CHANGED