-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EXAMPLE: Sort shorthand vs. longhand declarations — breaking change behind config #1700
base: master
Are you sure you want to change the base?
Conversation
|
✅ Deploy Preview for compiled-css-in-js canceled.
|
55fdf6d
to
a3a841d
Compare
…rting as well. Concerns: - Runtime sorting does not work properly as we'd also need per-bucket nested sorting where `@media, :focus, border` needs to be sorted. - `shorthandFor` needs 40 more shorthand properties defined…
a3a841d
to
bc029db
Compare
]} | ||
</Style> | ||
); | ||
|
||
// WARNING: This is wrong, the `focus` border properties are different than without focus, borders would be indeterministic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is required, all "bucket sorting" needs to be drastically rewritten to be nested.
Right now it's flat:
.abc { border: none }
.abc:link { border: none }
.abc:visited { border: none }
/* … */
.abc:active { border: none }
@media (/* … */) { .abc { border: none } }
But this doesn't support @media (…)
being sorted internally or .abc:focus { … }
being sorted against each other.
This would need deeper nested bucketing:
.abc { border: none }
.abc{ border-top: none }
.abc:link { border: none }
.abc:link { border-top: none }
@media (/* … */) {
.abc { border: none }
.abc { border-top: none }
.abc:active { border: none }
.abc:active { border-top: none }
}
And I'm not exactly sure if that's even feasible for @media
queries either…
…uents. This no longer sorts `border-top` vs. `border-block-start` as they are siblings, not a sibling of a constituent…
What is this change?
Adds sorting of shorthand vs. longhand to ensure longhand deterministically will override shorthand.
Why are we making this change?
This is because quite commonly this code may be applied in either direction meaning sometimes
font-weight: bold
is applied and sometimes it's not, depending on the order that the stylesheet was generated in.Example in a Storybook:
How are we making this change?
Where we already sort atomic styles, we now sort shorthand vs. longhand in that same area.
PR checklist
sortAtomicStyleSheet
iterates over all declarations or just one by one…outline
andfont
, there are many more!website/
with this new config