@sprlab/wccompiler 0.9.0 → 0.9.1

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.
Files changed (2) hide show
  1. package/lib/codegen.js +7 -5
  2. package/package.json +1 -1
package/lib/codegen.js CHANGED
@@ -1170,16 +1170,18 @@ export function generateComponent(parseResult, options = {}) {
1170
1170
  // ── Deferred slot re-check (Angular compatibility) ──
1171
1171
  // Angular connects custom elements to DOM BEFORE projecting children.
1172
1172
  // If no slot content was found on first pass, schedule a microtask retry.
1173
- // After the first render, Angular projects children as siblings after the template root.
1174
- // The microtask skips the first child (our rendered template) and parses the rest.
1173
+ // We save a reference to the rendered root node so the microtask can filter it out
1174
+ // and only process children that were projected by the framework after connectedCallback.
1175
1175
  if (slots.length > 0) {
1176
1176
  lines.push(' if (Object.keys(__slotMap).length === 0 && __defaultSlotNodes.length === 0) {');
1177
+ lines.push(' const __renderedRoot = this.firstElementChild;');
1177
1178
  lines.push(' queueMicrotask(() => {');
1178
1179
  lines.push(' const __sm = {};');
1179
1180
  lines.push(' const __dn = [];');
1180
- // Skip the first element child (our rendered template root)
1181
- lines.push(' const __children = Array.from(this.childNodes).slice(1);');
1182
- lines.push(' for (const child of __children) {');
1181
+ lines.push(' for (const child of Array.from(this.childNodes)) {');
1182
+ // Skip the rendered template root and any whitespace text nodes that were there before
1183
+ lines.push(' if (child === __renderedRoot) continue;');
1184
+ lines.push(' if (child.nodeType === 3 && !child.textContent.trim()) continue;');
1183
1185
  lines.push(" if (child.nodeName === 'TEMPLATE') {");
1184
1186
  lines.push(' for (const attr of child.attributes) {');
1185
1187
  lines.push(" if (attr.name.startsWith('#')) {");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprlab/wccompiler",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Zero-runtime compiler that transforms .wcc single-file components into native web components with signals-based reactivity",
5
5
  "type": "module",
6
6
  "exports": {