@sprlab/wccompiler 0.16.4 → 0.16.5
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 +20 -1
- package/package.json +1 -1
package/lib/codegen.js
CHANGED
|
@@ -1596,8 +1596,9 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
1596
1596
|
lines.push(' }));');
|
|
1597
1597
|
} else {
|
|
1598
1598
|
// String expression: set className
|
|
1599
|
+
// Wrap ternary/logical expressions to prevent precedence issues
|
|
1599
1600
|
lines.push(' this.__disposers.push(__effect(() => {');
|
|
1600
|
-
lines.push(` this.${ab.varName}.className = ${expr};`);
|
|
1601
|
+
lines.push(` this.${ab.varName}.className = ${wrapTernaryExpr(expr)};`);
|
|
1601
1602
|
lines.push(' }));');
|
|
1602
1603
|
}
|
|
1603
1604
|
} else if (ab.kind === 'style') {
|
|
@@ -1954,6 +1955,24 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
1954
1955
|
lines.push('');
|
|
1955
1956
|
}
|
|
1956
1957
|
|
|
1958
|
+
// Wrapper methods for defineModel signals (dual getter/setter)
|
|
1959
|
+
// These act as the interface between template code and internal signals
|
|
1960
|
+
// - As getter (no args): returns signal value
|
|
1961
|
+
// - As setter (with arg): calls _modelSet_* to update and dispatch events
|
|
1962
|
+
if (modelDefs.length > 0) {
|
|
1963
|
+
lines.push(' // --- Model wrapper methods ---');
|
|
1964
|
+
for (const md of modelDefs) {
|
|
1965
|
+
lines.push(` _${md.name}(val) {`);
|
|
1966
|
+
lines.push(` if (arguments.length === 0) {`);
|
|
1967
|
+
lines.push(` return this._m_${md.name}();`);
|
|
1968
|
+
lines.push(` } else {`);
|
|
1969
|
+
lines.push(` this._modelSet_${md.name}(val);`);
|
|
1970
|
+
lines.push(` }`);
|
|
1971
|
+
lines.push(` }`);
|
|
1972
|
+
lines.push('');
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1957
1976
|
// __scopedSlots instance getter and registerSlotRenderer (if scoped slots exist)
|
|
1958
1977
|
if (scopedSlotNames.length > 0) {
|
|
1959
1978
|
lines.push(' get __scopedSlots() { return this.constructor.__scopedSlots || []; }');
|
package/package.json
CHANGED