Skip to content

Commit c515a91

Browse files
Don’t reorder webkit scrollbar pseudo elements (#9991)
* Don’t reorder webkit scrollbar pseudo elements In reality, we need to stop reordering pseudo elements completely as `::before:hover` and `::after:hover` are 100% valid and should work per the CSS selector spec even though no browser currently supports it. * Update changelog
1 parent a124977 commit c515a91

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Support renaming of output files by `PostCSS` plugin. ([#9944](https://github.com/tailwindlabs/tailwindcss/pull/9944))
2222
- Improve return value of `resolveConfig`, unwrap `ResolvableTo` ([#9972](https://github.com/tailwindlabs/tailwindcss/pull/9972))
2323
- Clip unbalanced brackets in arbitrary values ([#9973](https://github.com/tailwindlabs/tailwindcss/pull/9973))
24+
- Don’t reorder webkit scrollbar pseudo elements ([#9991](https://github.com/tailwindlabs/tailwindcss/pull/9991))
2425

2526
### Changed
2627

src/util/formatVariantSelector.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,18 @@ export function finalizeSelector(
250250
let pseudoElementsBC = [':before', ':after', ':first-line', ':first-letter']
251251

252252
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
253-
let pseudoElementExceptions = ['::file-selector-button']
253+
let pseudoElementExceptions = [
254+
'::file-selector-button',
255+
256+
// Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
257+
'::-webkit-scrollbar',
258+
'::-webkit-scrollbar-button',
259+
'::-webkit-scrollbar-thumb',
260+
'::-webkit-scrollbar-track',
261+
'::-webkit-scrollbar-track-piece',
262+
'::-webkit-scrollbar-corner',
263+
'::-webkit-resizer',
264+
]
254265

255266
// This will make sure to move pseudo's to the correct spot (the end for
256267
// pseudo elements) because otherwise the selector will never work

tests/variants.test.js

+49
Original file line numberDiff line numberDiff line change
@@ -1096,3 +1096,52 @@ test('variant functions returning arrays should output correct results when nest
10961096
}
10971097
`)
10981098
})
1099+
1100+
test.only('arbitrary variant selectors should not re-order scrollbar pseudo classes', async () => {
1101+
let config = {
1102+
content: [
1103+
{
1104+
raw: html`
1105+
<div class="[&::-webkit-scrollbar:hover]:underline" />
1106+
<div class="[&::-webkit-scrollbar-button:hover]:underline" />
1107+
<div class="[&::-webkit-scrollbar-thumb:hover]:underline" />
1108+
<div class="[&::-webkit-scrollbar-track:hover]:underline" />
1109+
<div class="[&::-webkit-scrollbar-track-piece:hover]:underline" />
1110+
<div class="[&::-webkit-scrollbar-corner:hover]:underline" />
1111+
<div class="[&::-webkit-resizer:hover]:underline" />
1112+
`,
1113+
},
1114+
],
1115+
corePlugins: { preflight: false },
1116+
}
1117+
1118+
let input = css`
1119+
@tailwind utilities;
1120+
`
1121+
1122+
let result = await run(input, config)
1123+
1124+
expect(result.css).toMatchFormattedCss(css`
1125+
.\[\&\:\:-webkit-scrollbar\:hover\]\:underline::-webkit-scrollbar:hover {
1126+
text-decoration-line: underline;
1127+
}
1128+
.\[\&\:\:-webkit-scrollbar-button\:hover\]\:underline::-webkit-scrollbar-button:hover {
1129+
text-decoration-line: underline;
1130+
}
1131+
.\[\&\:\:-webkit-scrollbar-thumb\:hover\]\:underline::-webkit-scrollbar-thumb:hover {
1132+
text-decoration-line: underline;
1133+
}
1134+
.\[\&\:\:-webkit-scrollbar-track\:hover\]\:underline::-webkit-scrollbar-track:hover {
1135+
text-decoration-line: underline;
1136+
}
1137+
.\[\&\:\:-webkit-scrollbar-track-piece\:hover\]\:underline::-webkit-scrollbar-track-piece:hover {
1138+
text-decoration-line: underline;
1139+
}
1140+
.\[\&\:\:-webkit-scrollbar-corner\:hover\]\:underline::-webkit-scrollbar-corner:hover {
1141+
text-decoration-line: underline;
1142+
}
1143+
.\[\&\:\:-webkit-resizer\:hover\]\:underline::-webkit-resizer:hover {
1144+
text-decoration-line: underline;
1145+
}
1146+
`)
1147+
})

0 commit comments

Comments
 (0)