tailwindcss/packages
Srinu desetti 90f8ff41c8
Don't space out and/or/not inside function calls in supports-[…] variants (#20420)
## Summary

The `supports-[…]` variant works around a Chrome bug where `@supports
(a)or(b)`
is invalid by spacing out the `and`, `or`, and `not` keywords. However,
the
replacement is applied to the entire value, including the inside of
function
calls, where these words can be part of a selector.

For example, `supports-[selector(a:not(.foo))]:flex` generates:

```css
@supports selector(a: not (.foo))
```

The selector `a: not (.foo)` is unparsable, so a condition that is true
in
every browser silently becomes false and the utility never applies. The
same
happens to class names like `.and` or `.or` inside `selector(…)`.

This PR only spaces out the keywords at the condition level: parens
preceded by
an identifier (other than the keywords themselves) start a function
call, and
everything inside is left as-is. The Chrome workaround still applies to
the
condition itself, e.g. `supports-[(display:grid)or(display:flex)]` still
becomes `@supports (display: grid) or (display: flex)`.

## Test plan

- Added a test covering `selector(a:not(.foo))`, class names
`.and`/`.or`
inside `selector(…)`, the Chrome `(a)or(b)` workaround, and a top-level
  `not(…)` condition.
- `pnpm vitest run packages/tailwindcss/src/variants.test.ts` — 102
passed.

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2026-08-14 19:43:33 +00:00
..
@tailwindcss-browser Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-cli Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-node Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-postcss Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-standalone Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-turbopack Add Turbopack loader integration coverage 2026-07-31 15:13:38 +02:00
@tailwindcss-upgrade Bump dependencies (#20381) 2026-08-04 13:55:03 +02:00
@tailwindcss-vite Do not force full page reloads when using @tailwindcss/vite (#20414) 2026-08-13 17:00:08 +02:00
@tailwindcss-webpack 4.3.3 (#20334) 2026-07-16 07:21:50 -04:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Don't space out and/or/not inside function calls in supports-[…] variants (#20420) 2026-08-14 19:43:33 +00:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00