Skip to content

Commit e51b09c

Browse files
Move unknown pseudo elements outside of :is (#11345)
* More pseudo elements outside of `:is` by default * Update changelog
1 parent eb8d929 commit e51b09c

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Remove `autoprefixer` dependency ([#11315](https://github.com/tailwindlabs/tailwindcss/pull/11315))
1717
- Fix source maps issue resulting in a crash ([#11319](https://github.com/tailwindlabs/tailwindcss/pull/11319))
1818
- Fallback to RegEx based parser when using custom transformers or extractors ([#11335](https://github.com/tailwindlabs/tailwindcss/pull/11335))
19+
- Move unknown pseudo-elements outside of `:is` by default ([#11345](https://github.com/tailwindlabs/tailwindcss/pull/11345))
1920

2021
### Added
2122

src/util/pseudoElements.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
// **Jumpable**
2020
// Any terminal element may "jump" over combinators when moving to the end of the selector
2121
//
22-
// This is a backwards-compat quirk of :before and :after variants.
22+
// This is a backwards-compat quirk of pseudo element variants from earlier versions of Tailwind CSS.
2323

2424
/** @typedef {'terminal' | 'actionable' | 'jumpable'} PseudoProperty */
2525

2626
/** @type {Record<string, PseudoProperty[]>} */
2727
let elementProperties = {
28+
// Pseudo elements from the spec
2829
'::after': ['terminal', 'jumpable'],
2930
'::backdrop': ['terminal', 'jumpable'],
3031
'::before': ['terminal', 'jumpable'],
@@ -41,18 +42,14 @@ let elementProperties = {
4142
'::spelling-error': ['terminal'],
4243
'::target-text': ['terminal'],
4344

44-
// other
45+
// Pseudo elements from the spec with special rules
4546
'::file-selector-button': ['terminal', 'actionable'],
46-
'::-webkit-progress-bar': ['terminal', 'actionable'],
4747

48-
// Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
49-
'::-webkit-scrollbar': ['terminal', 'actionable'],
50-
'::-webkit-scrollbar-button': ['terminal', 'actionable'],
51-
'::-webkit-scrollbar-thumb': ['terminal', 'actionable'],
52-
'::-webkit-scrollbar-track': ['terminal', 'actionable'],
53-
'::-webkit-scrollbar-track-piece': ['terminal', 'actionable'],
54-
'::-webkit-scrollbar-corner': ['terminal', 'actionable'],
55-
'::-webkit-resizer': ['terminal', 'actionable'],
48+
// Library-specific pseudo elements used by component libraries
49+
// These are Shadow DOM-like
50+
'::deep': ['actionable'],
51+
'::v-deep': ['actionable'],
52+
'::ng-deep': ['actionable'],
5653

5754
// Note: As a rule, double colons (::) should be used instead of a single colon
5855
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
@@ -65,8 +62,8 @@ let elementProperties = {
6562

6663
// The default value is used when the pseudo-element is not recognized
6764
// Because it's not recognized, we don't know if it's terminal or not
68-
// So we assume it can't be moved AND can have user-action pseudo classes attached to it
69-
__default__: ['actionable'],
65+
// So we assume it can be moved AND can have user-action pseudo classes attached to it
66+
__default__: ['terminal', 'actionable'],
7067
}
7168

7269
/**

tests/util/apply-important-selector.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ it.each`
1616
${':is(.foo) :is(.bar)'} | ${'#app :is(:is(.foo) :is(.bar))'}
1717
${':is(.foo)::before'} | ${'#app :is(.foo)::before'}
1818
${'.foo:before'} | ${'#app :is(.foo):before'}
19+
${'.foo::some-uknown-pseudo'} | ${'#app :is(.foo)::some-uknown-pseudo'}
20+
${'.foo::some-uknown-pseudo:hover'} | ${'#app :is(.foo)::some-uknown-pseudo:hover'}
21+
${'.foo:focus::some-uknown-pseudo:hover'} | ${'#app :is(.foo:focus)::some-uknown-pseudo:hover'}
22+
${'.foo:hover::some-uknown-pseudo:focus'} | ${'#app :is(.foo:hover)::some-uknown-pseudo:focus'}
1923
`('should generate "$after" from "$before"', ({ before, after }) => {
2024
expect(applyImportantSelector(before, '#app')).toEqual(after)
2125
})

0 commit comments

Comments
 (0)