Skip to content

[style-value-parser] Fix BorderRadiusShorthand.toString dropping vertical radii#1759

Open
LeSingh1 wants to merge 1 commit into
facebook:mainfrom
LeSingh1:fix/border-radius-shorthand-vertical-tostring
Open

[style-value-parser] Fix BorderRadiusShorthand.toString dropping vertical radii#1759
LeSingh1 wants to merge 1 commit into
facebook:mainfrom
LeSingh1:fix/border-radius-shorthand-vertical-tostring

Conversation

@LeSingh1

Copy link
Copy Markdown
Contributor

Summary

BorderRadiusShorthand.toString() builds two strings: pStr from the horizontal radii (rendered before the /) and sStr from the vertical radii (after the /). sStr was initialized from the horizontal radii instead of the vertical ones:

let sStr = `${horizontalTopLeft} ${horizontalTopRight} ${horizontalBottomRight} ${horizontalBottomLeft}`;

The three reassignment branches below it all correctly use the vertical radii, but they only fire when the vertical radii have some symmetry (all equal, diagonal pairs equal, or topRight === bottomLeft). When all four vertical radii are distinct, none fire, so sStr keeps its horizontal initial value. That makes pStr === sStr, and toString returns just pStrsilently dropping the vertical radii.

Example:

'10px 20px 30px 40px / 40px 30px 20px 10px'  →  '10px 20px 30px 40px'   (before)
'10px 20px 30px 40px / 40px 30px 20px 10px'  →  '10px 20px 30px 40px / 40px 30px 20px 10px'  (after)

Fix

Initialize sStr from the vertical radii, matching the reassignment branches (one-line change).

Test

Added round-trip tests in border-radius.test.js: symmetric radii still serialize without a /, and asymmetric radii preserve the vertical values after the /. The asymmetric case fails before this change and passes after.

The fix is isolated to toString; the parser is unchanged. (I verified the exact toString branching against the buggy and fixed initializations with a standalone reproduction of the logic — the asymmetric case collapses before and round-trips after — since I couldn't run the full jest suite locally.)

…ical radii

The secondary (post-"/") string sStr was initialized from the
horizontal radii instead of the vertical ones. When the vertical radii
have no symmetry (all four distinct), none of the reassignment branches
fire, so sStr kept the horizontal values, made pStr === sStr, and the
whole value collapsed to just the horizontal radii -- silently dropping
the vertical radii (e.g. "10px 20px 30px 40px / 40px 30px 20px 10px"
serialized as "10px 20px 30px 40px"). Initialize sStr from the vertical
radii to match the reassignment branches.
@LeSingh1
LeSingh1 requested review from mellyeliu and nmn as code owners July 15, 2026 04:17
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
stylex Skipped Skipped Jul 15, 2026 4:17am

Request Review

@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 15, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant