diff --git a/CHANGELOG.md b/CHANGELOG.md index 2547f13b8ee2..ffcdd5bbd9f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Improve support for raw `supports-[…]` queries in arbitrary values ([#13605](https://github.com/tailwindlabs/tailwindcss/pull/13605)) ## [3.4.17] - 2024-12-17 diff --git a/src/corePlugins.js b/src/corePlugins.js index 8f274153879e..b73c67256a18 100644 --- a/src/corePlugins.js +++ b/src/corePlugins.js @@ -409,8 +409,8 @@ export let variantPlugins = { matchVariant( 'supports', (value = '') => { - let check = normalize(value) - let isRaw = /^\w*\s*\(/.test(check) + let check = value.startsWith('--') ? value : normalize(value) + let isRaw = /^[\w-]*\s*\(/.test(check) // Chrome has a bug where `(condition1)or(condition2)` is not valid // But `(condition1) or (condition2)` is supported. diff --git a/tests/arbitrary-variants.test.js b/tests/arbitrary-variants.test.js index fce5f0576e17..6807f2cb497e 100644 --- a/tests/arbitrary-variants.test.js +++ b/tests/arbitrary-variants.test.js @@ -767,18 +767,28 @@ it('should support supports', () => {
- - + + + + + + + + + + + + `, }, @@ -791,45 +801,73 @@ it('should support supports', () => { ` return run(input, config).then((result) => { - expect(result.css).toMatchFormattedCss(css` - @supports (display: grid) { - .supports-grid\:underline { - text-decoration-line: underline; - } - .supports-\[display\:grid\]\:grid { - display: grid; - } + expect(result.css).toMatchInlineSnapshot(` + "@supports (display: grid) { + .supports-grid\\:underline { + text-decoration-line: underline + } } - @supports (foo: bar) and (bar: baz) { - .supports-\[\(foo\:bar\)and\(bar\:baz\)\]\:underline { - text-decoration-line: underline; - } + @supports (--test: var(--tw)) { + .supports-\\[--test\\]\\:flex { + display: flex + } } - @supports (foo: bar) or (bar: baz) { - .supports-\[\(foo\:bar\)or\(bar\:baz\)\]\:underline { - text-decoration-line: underline; - } + @supports font-tech(color-COLRv1) { + .supports-\\[font-tech\\(color-COLRv1\\)\\]\\:flex { + display: flex + } + } + @supports (foo:bar) and (bar:baz) { + .supports-\\[\\(foo\\:bar\\)_and_\\(bar\\:baz\\)\\]\\:grid { + display: grid + } + } + @supports (foo:bar) and (bar:baz) or (baz:qux) { + .supports-\\[\\(foo\\:bar\\)_and_\\(bar\\:baz\\)_or\\(baz\\:qux\\)\\]\\:grid { + display: grid + } + } + @supports (display:grid) { + .supports-\\[display\\:grid\\]\\:grid { + display: grid + } + } + @supports font-format(opentype) { + .supports-\\[font-format\\(opentype\\)\\]\\:grid { + display: grid + } + } + @supports (foo:bar) and (bar:baz) { + .supports-\\[\\(foo\\:bar\\)and\\(bar\\:baz\\)\\]\\:underline { + text-decoration-line: underline + } + } + @supports (foo:bar) or (bar:baz) { + .supports-\\[\\(foo\\:bar\\)or\\(bar\\:baz\\)\\]\\:underline { + text-decoration-line: underline + } } @supports (container-type: var(--tw)) { - .supports-\[container-type\]\:underline { - text-decoration-line: underline; - } + .supports-\\[container-type\\]\\:underline { + text-decoration-line: underline + } } - @supports not (foo: bar) { - .supports-\[not\(foo\:bar\)\]\:underline { - text-decoration-line: underline; - } + @supports not (foo:bar) { + .supports-\\[not\\(foo\\:bar\\)\\]\\:underline { + text-decoration-line: underline + } } @supports selector(A > B) { - .supports-\[selector\(A_\>_B\)\]\:underline { - text-decoration-line: underline; - } + .supports-\\[selector\\(A_\\>_B\\)\\]\\:underline { + text-decoration-line: underline + } } - @supports (transform-origin: 5% 5%) { - .supports-\[transform-origin\:5\%_5\%\]\:underline { - text-decoration-line: underline; - } + @supports (transform-origin:5% 5%) { + .supports-\\[transform-origin\\:5\\%_5\\%\\]\\:underline { + text-decoration-line: underline + } } + " `) }) })