Fix Inset.toString() shortest-form serialization#1744
Open
durvesh1992 wants to merge 1 commit into
Open
Conversation
Inset.toString() had three defects that produced non-minimal or invalid
output (it had no prior toString test coverage):
- The 1-value collapse compared `left === round` (the border-radius
value, handled separately and usually null) instead of `left === top`,
so it never fired: inset(10px) serialized as 'inset(10px 10px)'.
- The 3-value branch keyed on `top === bottom` instead of `left ===
right`, so a 3-value input round-tripped to 4 values and an asymmetric
case like inset(10px 20px 10px 40px) could drop the left value.
- The 4-value branch emitted a stray space before the closing paren
('inset(10px 20px 30px 40px )').
Adds a round-trip test covering the 1/2/3/4-value and round forms.
|
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
Inset.toString()(in@stylexjs/style-value-parser) aims to emit the shortest validinset()form, but had three defects (the method had no priortoString()test coverage):left === round—roundis the border-radius value, handled separately viaroundStrand usuallynull— instead ofleft === top. Soinset(10px)serialized asinset(10px 10px).top === bottominstead ofleft === right(the condition the 3-value form actually requires), so a 3-value input round-tripped to 4 values, and an asymmetric case likeinset(10px 20px 10px 40px)could drop theleftvalue.inset(10px 20px 30px 40px )(space before)).Test plan
Added a round-trip test in
basic-shape.jscovering the 1/2/3/4-value androundforms (fails before, passes after). Full package suite green: