diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a8220c75976..5507dad21221 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support renaming of output files by `PostCSS` plugin. ([#9944](https://github.com/tailwindlabs/tailwindcss/pull/9944)) - Improve return value of `resolveConfig`, unwrap `ResolvableTo` ([#9972](https://github.com/tailwindlabs/tailwindcss/pull/9972)) - Clip unbalanced brackets in arbitrary values ([#9973](https://github.com/tailwindlabs/tailwindcss/pull/9973)) +- Don’t reorder webkit scrollbar pseudo elements ([#9991](https://github.com/tailwindlabs/tailwindcss/pull/9991)) ### Changed diff --git a/src/util/formatVariantSelector.js b/src/util/formatVariantSelector.js index ae6aa69a0a29..79c94fae8385 100644 --- a/src/util/formatVariantSelector.js +++ b/src/util/formatVariantSelector.js @@ -250,7 +250,18 @@ export function finalizeSelector( let pseudoElementsBC = [':before', ':after', ':first-line', ':first-letter'] // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter. -let pseudoElementExceptions = ['::file-selector-button'] +let pseudoElementExceptions = [ + '::file-selector-button', + + // Webkit scroll bar pseudo elements can be combined with user-action pseudo classes + '::-webkit-scrollbar', + '::-webkit-scrollbar-button', + '::-webkit-scrollbar-thumb', + '::-webkit-scrollbar-track', + '::-webkit-scrollbar-track-piece', + '::-webkit-scrollbar-corner', + '::-webkit-resizer', +] // This will make sure to move pseudo's to the correct spot (the end for // pseudo elements) because otherwise the selector will never work diff --git a/tests/variants.test.js b/tests/variants.test.js index ab5622d13929..b9ae7f831aa2 100644 --- a/tests/variants.test.js +++ b/tests/variants.test.js @@ -1096,3 +1096,52 @@ test('variant functions returning arrays should output correct results when nest } `) }) + +test.only('arbitrary variant selectors should not re-order scrollbar pseudo classes', async () => { + let config = { + content: [ + { + raw: html` +
+
+
+
+
+
+
+ `, + }, + ], + corePlugins: { preflight: false }, + } + + let input = css` + @tailwind utilities; + ` + + let result = await run(input, config) + + expect(result.css).toMatchFormattedCss(css` + .\[\&\:\:-webkit-scrollbar\:hover\]\:underline::-webkit-scrollbar:hover { + text-decoration-line: underline; + } + .\[\&\:\:-webkit-scrollbar-button\:hover\]\:underline::-webkit-scrollbar-button:hover { + text-decoration-line: underline; + } + .\[\&\:\:-webkit-scrollbar-thumb\:hover\]\:underline::-webkit-scrollbar-thumb:hover { + text-decoration-line: underline; + } + .\[\&\:\:-webkit-scrollbar-track\:hover\]\:underline::-webkit-scrollbar-track:hover { + text-decoration-line: underline; + } + .\[\&\:\:-webkit-scrollbar-track-piece\:hover\]\:underline::-webkit-scrollbar-track-piece:hover { + text-decoration-line: underline; + } + .\[\&\:\:-webkit-scrollbar-corner\:hover\]\:underline::-webkit-scrollbar-corner:hover { + text-decoration-line: underline; + } + .\[\&\:\:-webkit-resizer\:hover\]\:underline::-webkit-resizer:hover { + text-decoration-line: underline; + } + `) +})