[style-value-parser] Fix BorderRadiusShorthand.toString dropping vertical radii#1759
Open
LeSingh1 wants to merge 1 commit into
Open
[style-value-parser] Fix BorderRadiusShorthand.toString dropping vertical radii#1759LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
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.
Summary
BorderRadiusShorthand.toString()builds two strings:pStrfrom the horizontal radii (rendered before the/) andsStrfrom the vertical radii (after the/).sStrwas initialized from the horizontal radii instead of the vertical ones: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, sosStrkeeps its horizontal initial value. That makespStr === sStr, andtoStringreturns justpStr— silently dropping the vertical radii.Example:
Fix
Initialize
sStrfrom 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 exacttoStringbranching 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.)