Skip to content

Accept unitless zero stops and reject invalid layers in backgroundImage strings - #59609

Merged
javache merged 1 commit into
react:mainfrom
lazerg:fix/issue-59603-background-image-parsing
Oct 30, 2026
Merged

javache merged 1 commit into
react:mainfrom
lazerg:fix/issue-59603-background-image-parsing

Conversation

@lazerg

@lazerg lazerg commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Summary:

Two bugs in the backgroundImage string parser. getPositionFromCSSValue only accepted px and %, so a unitless 0 stop like linear-gradient(red 0, blue 100%) was treated as an invalid position and the whole gradient was dropped. CSS allows a bare 0 as a length, so it now parses to 0.

Also, when one layer of a multi-layer string failed to parse, parseBackgroundImageCSSString skipped it and kept the others. In CSS one invalid layer invalidates the whole value, and the array form here already returns [] in that case, so the string form now does the same.

Fixes #59603

Changelog:

[GENERAL] [FIXED] - Accept unitless 0 color stop positions and drop the whole value when one layer is invalid in backgroundImage strings

Test Plan:

Added two cases to processBackgroundImage-itest.js. Both fail on main and pass with this change, and the rest of the file still passes. I ran the file under plain Jest (without the Fantom environment import) since I don't have the Fantom runner built locally. Prettier, ESLint and Flow are clean.

@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 Oct 29, 2026
@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 Oct 29, 2026
@meta-codesync

meta-codesync Bot commented Oct 29, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D128423602.

@javache
javache merged commit 54905a2 into react:main Oct 30, 2026
110 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. 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.

backgroundImage strings: a unitless 0 stop drops the gradient, and an invalid layer is skipped instead of invalidating the value

2 participants