Skip to content

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

Open
lazerg wants to merge 1 commit into
react:mainfrom
lazerg:fix/issue-59603-background-image-parsing
Open

lazerg wants to merge 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

This branch has not been deployed

No deployments
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.

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

1 participant