Skip to content

fix: decimal values in transformOrigin string parser#57487

Open
MayankSharma-2812 wants to merge 1 commit into
react:mainfrom
MayankSharma-2812:fix-transform-origin-decimal-values
Open

fix: decimal values in transformOrigin string parser#57487
MayankSharma-2812 wants to merge 1 commit into
react:mainfrom
MayankSharma-2812:fix-transform-origin-decimal-values

Conversation

@MayankSharma-2812

Copy link
Copy Markdown

Summary:

Fixes incorrect parsing of decimal percentage and pixel values in the string form of transformOrigin.

The current tokenizer only matches integer numeric values followed by % or px. As a result, decimal pixel values are silently corrupted. For example:

processTransformOrigin('12.5px 7.5px');

currently returns:

[5, 5, 0]

instead of:

[12.5, 7.5, 0]

Decimal percentage values are also incorrectly tokenized. For example, 50.5% 30.2% is split into partial matches instead of preserving the decimal values.

This updates the numeric token pattern from \d+(?:%|px) to \d*\.?\d+(?:%|px), supporting decimal values such as 12.5px, 50.5%, and leading-dot decimal values such as .5%.

Regression coverage is added for decimal percentages, decimal pixels, and leading-dot decimal values.

Changelog:

[GENERAL] [FIXED] - Fix transformOrigin string parsing for decimal percentage and pixel values.

Test Plan:

Added regression coverage in processTransformOrigin-itest.js for:

  • decimal percentages: 50.5% 30.2%
  • decimal pixels: 12.5px 7.5px
  • leading-dot decimals: .5% .5px

A focused local execution against processTransformOrigin confirmed:

Before fix:
"12.5px 7.5px" -> [5, 5, 0]

After fix:
"12.5px 7.5px" -> [12.5, 7.5, 0]

Also attempted the targeted Fantom integration test with:

node node_modules/jest/bin/jest.js --config private/react-native-fantom/config/jest.config.js packages/react-native/Libraries/StyleSheet/__tests__/processTransformOrigin-itest.js

The Fantom test could not complete locally because Metro failed to resolve a generated runtime setup path containing Windows path separators.

@meta-cla

meta-cla Bot commented Jul 8, 2026

Copy link
Copy Markdown

Hi @MayankSharma-2812!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@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 Jul 8, 2026
@meta-cla

meta-cla Bot commented Jul 8, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 8, 2026
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant