Skip to content

[babel-plugin] treat fontSizeAdjust as a unitless number - #1903

Merged
mellyeliu merged 1 commit into
meta:mainfrom
Om-singhaI:fix-font-size-adjust-unitless
Sep 23, 2026
Merged

mellyeliu merged 1 commit into
meta:mainfrom
Om-singhaI:fix-font-size-adjust-unitless

Conversation

@Om-singhaI

Copy link
Copy Markdown
Contributor

What changed / motivation ?

transformValue turns a numeric style value into a string and asks getNumberSuffix what unit to append. getNumberSuffix falls back to px when the key is not in unitlessNumberProperties and has no entry in numberPropertySuffixes. fontSizeAdjust was in neither, so fontSizeAdjust: 0.545 compiled to font-size-adjust:.545px. font-size-adjust takes a plain number, so the browser drops the declaration and the property does nothing.

The Flow type for this property is 'none' | number, so a number is what users are told to write. A string like '0.545' does compile to valid CSS, because strings never reach getNumberSuffix, but Flow rejects it. Dynamic styles already emit the value unitless through a custom property, so static and dynamic styles produced different CSS for the same input.

  • Added fontSizeAdjust to unitlessNumberProperties in shared/utils/transform-value.js, next to fontWeight.
  • Extended the existing unitless case in transform-value-normalization-test.js with fontSizeAdjust: 0.545, the same way [babel-plugin] fix unitless zoom bug #1346 extended it with zoom: 2.

Same shape of fix as #1346 for zoom and #705 for the grid properties.

Linked PR/Issues

Fixes #1902

Additional Context

Only fontSizeAdjust changes. No other key moves in or out of the set, and no existing snapshot changed.

Testing, all measured on this branch against main at 20f2a50 with Node 25.6.1 and jest 30.1.3, run from packages/@stylexjs/babel-plugin:

  • npx jest __tests__/transform-value-normalization-test.js: 1 suite, 18 tests passed, 19 snapshots passed.
  • npx jest __tests__/transform-value-normalization-test.js __tests__/transform-stylex-create-test.js: 2 suites, 118 tests passed, 217 snapshots passed.
  • npx jest src/shared/utils/__tests__: 3 suites, 28 tests passed.
  • npx jest __tests__/transform-stylex-keyframes-test.js __tests__/transform-stylex-props-test.js __tests__/validation-stylex-create-test.js: 3 suites, 141 passed, 58 skipped, 113 snapshots passed.
  • Negative control: with transform-value.js restored from main and the new test kept, npx jest __tests__/transform-value-normalization-test.js gives 1 failed and 17 passed, and the snapshot diff reads .x1v6sj9q{font-size-adjust:.545} against .xq0srfb{font-size-adjust:.545px}.
  • prettier 3.5.3 --check and eslint 8.57.1 are clean on both changed files.
  • The repro from the issue now prints .x1v6sj9q{font-size-adjust:.545} where it printed .xq0srfb{font-size-adjust:.545px} before.
  • fontSizeAdjust: 0.545 and fontSizeAdjust: '0.545' now compile to the same rule, .x1v6sj9q{font-size-adjust:.545}. 0 still gives font-size-adjust:0, 'none' still gives font-size-adjust:none, and the dynamic form still gives font-size-adjust:var(--x-fontSizeAdjust).

Pre-flight checklist

Copilot AI lite review requested due to automatic review settings September 23, 2026 16:50
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 23, 2026
@vercel

vercel Bot commented Sep 23, 2026

Copy link
Copy Markdown

@Om-singhaI is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Fixes Babel plugin normalization so numeric fontSizeAdjust values compile as unitless CSS.

Changes:

  • Registers fontSizeAdjust as unitless.
  • Adds regression coverage for generated CSS.
File Description
packages/​@stylexjs/​babel-plugin/​src/​shared/​utils/​transform-value.js Treats fontSizeAdjust numbers as unitless.
packages/​@stylexjs/​babel-plugin/​__tests__/​transform-value-normalization-test.js Verifies unitless CSS output.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mellyeliu
mellyeliu merged commit 74e3ee0 into meta:main Sep 23, 2026
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[babel-plugin] fontSizeAdjust: 0.545 compiles to font-size-adjust:.545px, which browsers drop

3 participants