-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve relative precedence of
rtl
, ltr
, forced-colors
and `dar…
…k` variants (#12584) * Reduce specificity of `rtl`, `ltr`, and `dark` variants Reduce specificity of `rtl`, `ltr`, and `dark` variants (when using `darkMode: 'class'`) to make them the same as other variants. This also sorts the LTR/RTL and dark variants later in the variant plugin list to ensure that the reduced specificity doesn't cause them to start "losing" to other variants to keep things as backwards compatible as possible. Resolves a long-standing issue where `darkMode: 'media'` and `darkMode: 'class'` had different specificity, which meant switching your dark mode strategy could break your site. * Update changelog --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
- Loading branch information
1 parent
c5d3aab
commit af7e610
Showing
16 changed files
with
136 additions
and
112 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import { applyImportantSelector } from '../src/util/applyImportantSelector' | ||
|
||
it.each` | ||
before | after | ||
${'.foo'} | ${'#app :is(.foo)'} | ||
${'.foo .bar'} | ${'#app :is(.foo .bar)'} | ||
${'.foo:hover'} | ${'#app :is(.foo:hover)'} | ||
${'.foo .bar:hover'} | ${'#app :is(.foo .bar:hover)'} | ||
${'.foo::before'} | ${'#app :is(.foo)::before'} | ||
${'.foo::before'} | ${'#app :is(.foo)::before'} | ||
${'.foo::file-selector-button'} | ${'#app :is(.foo)::file-selector-button'} | ||
${'.foo::-webkit-progress-bar'} | ${'#app :is(.foo)::-webkit-progress-bar'} | ||
${'.foo:hover::before'} | ${'#app :is(.foo:hover)::before'} | ||
${':is(.dark :is([dir="rtl"] .foo::before))'} | ${'#app :is(.dark :is([dir="rtl"] .foo))::before'} | ||
${':is(.dark .foo) .bar'} | ${'#app :is(:is(.dark .foo) .bar)'} | ||
${':is(.foo) :is(.bar)'} | ${'#app :is(:is(.foo) :is(.bar))'} | ||
${':is(.foo)::before'} | ${'#app :is(.foo)::before'} | ||
${'.foo:before'} | ${'#app :is(.foo):before'} | ||
${'.foo::some-unknown-pseudo'} | ${'#app :is(.foo)::some-unknown-pseudo'} | ||
${'.foo::some-unknown-pseudo:hover'} | ${'#app :is(.foo)::some-unknown-pseudo:hover'} | ||
${'.foo:focus::some-unknown-pseudo:hover'} | ${'#app :is(.foo:focus)::some-unknown-pseudo:hover'} | ||
${'.foo:hover::some-unknown-pseudo:focus'} | ${'#app :is(.foo:hover)::some-unknown-pseudo:focus'} | ||
before | after | ||
${'.foo'} | ${'#app :is(.foo)'} | ||
${'.foo .bar'} | ${'#app :is(.foo .bar)'} | ||
${'.foo:hover'} | ${'#app :is(.foo:hover)'} | ||
${'.foo .bar:hover'} | ${'#app :is(.foo .bar:hover)'} | ||
${'.foo::before'} | ${'#app :is(.foo)::before'} | ||
${'.foo::before'} | ${'#app :is(.foo)::before'} | ||
${'.foo::file-selector-button'} | ${'#app :is(.foo)::file-selector-button'} | ||
${'.foo::-webkit-progress-bar'} | ${'#app :is(.foo)::-webkit-progress-bar'} | ||
${'.foo:hover::before'} | ${'#app :is(.foo:hover)::before'} | ||
${':is(:where(.dark) :is(:where([dir="rtl"]) .foo::before))'} | ${'#app :is(:where(.dark) :is(:where([dir="rtl"]) .foo))::before'} | ||
${':is(:where(.dark) .foo) .bar'} | ${'#app :is(:is(:where(.dark) .foo) .bar)'} | ||
${':is(.foo) :is(.bar)'} | ${'#app :is(:is(.foo) :is(.bar))'} | ||
${':is(.foo)::before'} | ${'#app :is(.foo)::before'} | ||
${'.foo:before'} | ${'#app :is(.foo):before'} | ||
${'.foo::some-unknown-pseudo'} | ${'#app :is(.foo)::some-unknown-pseudo'} | ||
${'.foo::some-unknown-pseudo:hover'} | ${'#app :is(.foo)::some-unknown-pseudo:hover'} | ||
${'.foo:focus::some-unknown-pseudo:hover'} | ${'#app :is(.foo:focus)::some-unknown-pseudo:hover'} | ||
${'.foo:hover::some-unknown-pseudo:focus'} | ${'#app :is(.foo:hover)::some-unknown-pseudo:focus'} | ||
`('should generate "$after" from "$before"', ({ before, after }) => { | ||
expect(applyImportantSelector(before, '#app')).toEqual(after) | ||
}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.