Skip to content

Commit cf9fef4

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

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
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Fix issue where some pseudo-element variants generated the wrong selector ([#10943](https://github.com/tailwindlabs/tailwindcss/pull/10943), [#10962](https://github.com/tailwindlabs/tailwindcss/pull/10962))
1313
- Fix parsing of `theme()` inside `calc()` when there are no spaces around operators ([#11157](https://github.com/tailwindlabs/tailwindcss/pull/11157))
1414
- Ensure `repeating-conic-gradient` is detected as an image ([#11180](https://github.com/tailwindlabs/tailwindcss/pull/11180))
15+
- Move unknown pseudo-elements outside of `:is` by default ([#11345](https://github.com/tailwindlabs/tailwindcss/pull/11345))
1516

1617
## [3.3.2] - 2023-04-25
1718

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
@@ -18,6 +18,10 @@ crosscheck(() => {
1818
${':is(.foo) :is(.bar)'} | ${'#app :is(:is(.foo) :is(.bar))'}
1919
${':is(.foo)::before'} | ${'#app :is(.foo)::before'}
2020
${'.foo:before'} | ${'#app :is(.foo):before'}
21+
${'.foo::some-uknown-pseudo'} | ${'#app :is(.foo)::some-uknown-pseudo'}
22+
${'.foo::some-uknown-pseudo:hover'} | ${'#app :is(.foo)::some-uknown-pseudo:hover'}
23+
${'.foo:focus::some-uknown-pseudo:hover'} | ${'#app :is(.foo:focus)::some-uknown-pseudo:hover'}
24+
${'.foo:hover::some-uknown-pseudo:focus'} | ${'#app :is(.foo:hover)::some-uknown-pseudo:focus'}
2125
`('should generate "$after" from "$before"', ({ before, after }) => {
2226
expect(applyImportantSelector(before, '#app')).toEqual(after)
2327
})

0 commit comments

Comments
 (0)