@sola-air-ui/compiler 1.0.5 → 1.0.6

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/package.json +1 -1
  2. package/src/index.js +5 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sola-air-ui/compiler",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Compiler for Sola single-file components (.sola) — transforms template + script + style to ES modules",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -440,7 +440,11 @@ export function compile(source, options = {}) {
440
440
  const id = `e${uid++}`;
441
441
  domCode += ` const ${id} = document.createTextNode('');\n`;
442
442
  domCode += ` ${parentVar}.appendChild(${id});\n`;
443
- domCode += ` createEffect(() => { ${id}.textContent = String(${expr} ?? ''); });\n`;
443
+ // Parenthesize expr before `?? ''`: JS forbids mixing ?? with || or && at the
444
+ // same level without explicit grouping (e.g. `col.label || col ?? ''` is a
445
+ // SyntaxError), and any {a || b}-style fallback expression — an extremely
446
+ // common pattern — would otherwise produce invalid generated code.
447
+ domCode += ` createEffect(() => { ${id}.textContent = String((${expr}) ?? ''); });\n`;
444
448
  return;
445
449
  }
446
450