[babel-plugin] stop adding px to unitless numbers in keyframes and viewTransitionClass - #1897
Open
Om-singhaI wants to merge 1 commit into
Open
Om-singhaI wants to merge 1 commit into
Om-singhaI wants to merge 1 commit into
Conversation
…ewTransitionClass styleXKeyframes and styleXViewTransitionClass dashify the property keys before they call transformValue. getNumberSuffix only knows camelCase names, so it never finds `font-weight`, `line-height`, `z-index` or `animation-iteration-count` in the unitless list and appends `px` to them. `fontWeight: 700` in a keyframe compiles to `font-weight:700px`, which the browser drops, so that part of the animation never runs. `lineHeight: 1.5` compiles to `line-height:1.5px`, which is valid but wrong. The same numbers in stylex.create compile correctly, because convertStyleToClassName passes the camelCase key to transformValue and dashifies it only for the rule. Run transformValue first and dashify afterwards, the same order stylex.create uses. Output only changes where the dashed key sent transformValue down the wrong path: numbers on multi word properties from the unitless list or the `ms` suffix table, `fontSize` with `enableFontSizePxToRem`, and camelCase values in `transitionProperty` and `willChange`. All of these now match stylex.create.
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches stylex.create behavior and includes focused regression tests.
Pull request overview
Fixes incorrect px suffixes in keyframes and view-transition styles by transforming values before dashifying property names.
Changes:
- Reordered value transformation and key dashification.
- Added snapshot coverage for unitless numeric properties.
File summaries
| File | Description |
|---|---|
stylex-keyframes.js |
Corrects keyframe value normalization order. |
stylex-view-transition-class.js |
Corrects view-transition value normalization order. |
transform-stylex-keyframes-test.js |
Tests unitless keyframe values. |
transform-stylex-viewTransitionClass-test.js |
Tests unitless view-transition values. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@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. |
This branch has not been deployed
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.
Fixes #1896
What changed / motivation ?
styleXKeyframesandstyleXViewTransitionClassrunobjMapKeys(x, dashify)beforetransformValue.getNumberSuffixlooks keys up in tables that only have camelCase names, sofont-weight,line-height,z-indexandanimation-iteration-countall miss the unitless list and getpx.fontWeight: 700in a keyframe ends up asfont-weight:700px.stylex.createdoesn't hit this becauseconvertStyleToClassNamepasses the camelCase key totransformValueand only dashifies it for the rule..pipe()steps inshared/stylex-keyframes.jsandshared/stylex-view-transition-class.js. Values are transformed with the camelCase key and the keys are dashified after, same order asstylex.create.fontWeight,lineHeightandzIndextotransform-stylex-keyframes-test.js, and one withanimationIterationCount: 2totransform-stylex-viewTransitionClass-test.js.Linked PR/Issues
None besides the issue above.
Additional Context
Output only changes where the dashed key sent
transformValuedown the wrong path. Besides the unitless numbers, that's:ms(animationDuration,animationDelay,transitionDuration,transitionDelay,voiceDuration). They used to getpx, soanimationDuration: 300in a view transition class came out as300px. Now it's.3s, same asstylex.create.fontSizewithenableFontSizePxToRem. Both functions now get the rem conversionstylex.createalready does.transitionPropertyorwillChange.No existing snapshot changed.
shared/stylex-position-try.jshas the same order, but none of the properties it allows come out any different with the camelCase key, so I left it alone.Testing:
pxvalues) and pass here.@stylexjs/babel-plugintests pass: 996 passed, 64 skipped (994 passed on main).font-weight:400,line-height:1.2,z-index:1in the keyframes andanimation-iteration-count:2on the view transition group.Pre-flight checklist
Contribution Guidelines