fix(compiler,ui): emit numeric/boolean raw CSS declarations [#2783]#2799
Merged
Conversation
`extract_css_declarations` (Rust) only accepted StringLiteral values, so
numeric, unary-negative, and boolean values inside raw object form (e.g.
`{ '&:hover': { fontSize: 16 } }`) were silently dropped from the AOT
output. The TS runtime path emitted the values but skipped camelCase →
kebab-case conversion and the unitless/`px` rules.
Both paths now route values through the shared formatter:
- Rust `extract_css_declarations` calls `extract_scalar_value` +
`format_style_value`, accepting NumericLiteral, BooleanLiteral, and
UnaryExpression(-, NumericLiteral) in addition to StringLiteral.
- TS `formatRawDeclaration` mirrors the same logic in `css.ts`.
Behaviour matches the existing TS↔Rust unitless parity test:
- `fontSize: 16` → `font-size: 16px` (dimensional)
- `opacity: 1`, `lineHeight: 1.5`, `zIndex: 10` → no `px` (unitless)
- `padding: 0` → `0` (zero is unitless)
- `'--my-tone': 1` → `--my-tone: 1` (custom prop)
- `marginTop: -8` → `margin-top: -8px` (negative)
Closes #2783.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9c4ecb7 to
5956ddf
Compare
This was referenced Apr 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2783. Raw object declarations inside
css({...})andvariants({...})selectors used to silently drop non-string values. Numeric, unary-negative, and boolean values now flow through the same kebab-case + unitless/pxformatting in both the AOT compiler and the runtime.Public API Changes
Additions — none. The fix removes a silent data loss in an existing API path; no signatures change.
Breaking — none.
What changed
native/vertz-compiler-core/src/css_transform.rsis_static_scalar_valueandis_static_css_declarationsnow acceptBooleanLiteralalongsideStringLiteral,NumericLiteral, andUnaryExpression(-, NumericLiteral).extract_scalar_valueadds aBooleanLiteral → StyleDeclValue::String(b.value.to_string())arm.extract_css_declarationswas rewritten to useextract_scalar_value+format_style_value(instead of the StringLiteral-only path), and skips empty property keys.packages/ui/src/css/css.tsformatRawDeclaration()helper that mirrors the AOT compiler'sextract_css_declarations(camelCase → kebab-case,formatStyleValueforpx/unitless rules, custom-property passthrough).fontSize: 16(no kebab, nopx) inside nested raw decls — fixed.packages/ui/src/css/__tests__/css-raw-declarations.test.ts.changeset/css-raw-decl-numeric-extraction.md(patch).Test Plan
cargo test --allgreen (74 tests incss_transform)cargo clippy --all-targets -- -D warningscleancargo fmt --all -- --checkcleanoxlint packages/clean on changed filesoxfmt --check packages/cleanreviews/issue-2783/phase-01-numeric-extraction.md— no blockers, both should-fix items addressedCloses #2783.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com