Skip to content

Commit 4b900cb

Browse files
committed
fix: non-if-properties
When CSS rules contained both if()AND non-if() properties, the non-if() properties were dropped
1 parent 085c082 commit 4b900cb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/transform.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ const transformToNativeCSS = (cssText) => {
469469
}
470470

471471
let hasIfConditions = false;
472+
const nonIfProperties = [];
472473

473474
for (const { property, value } of rule.properties) {
474475
if (value.includes('if(')) {
@@ -487,10 +488,17 @@ const transformToNativeCSS = (cssText) => {
487488
runtimeCSS += transformed.runtimeCSS + '\n';
488489
hasRuntimeRules = true;
489490
}
491+
} else {
492+
// Collect non-if() properties to preserve them
493+
nonIfProperties.push(`${property}: ${value}`);
490494
}
491495
}
492496

493-
if (!hasIfConditions) {
497+
// If we have non-if() properties in a rule that also has if() properties,
498+
// we need to create a base rule with those properties
499+
if (hasIfConditions && nonIfProperties.length > 0) {
500+
nativeCSS += `${rule.selector} { ${nonIfProperties.join('; ')}; }\n`;
501+
} else if (!hasIfConditions) {
494502
// Keep rules without if() conditions as-is
495503
nativeCSS += ruleText + '\n';
496504
}

0 commit comments

Comments
 (0)