tailwindcss/packages
Robin Malfait 73f3a6a743
Canonicalization: migrate [&:has(…)] to has-[…] variant (#19991)
This PR improves the canonicalization around arbitrary variants
containing `[&:has(…)]`, by converting them to `has-[…]`.

Essentially when you have a variant, with `&:has(…)`, we will convert
it:

```diff
- [&:has([role=checkbox])]:flex
+ has-[[role=checkbox]]:flex
```

This also means that if the arbitrary selector inside of the `&:has(…)`
can be converted to something that aligns with known variants, then we
will do that as well:

```diff
  // `data-*` can be hoisted outside of the arbitrary value
- [&:has([data-slot=description])]:flex
+ has-data-[slot=description]:flex

  // `aria-visible="true"` can be entirely replaced by `aria-visible`
- [&:has([aria-visible="true"])]:flex
+ has-aria-visible:flex
```

Noticed this while looking into:
https://github.com/tailwindlabs/tailwindcss-intellisense/issues/1562

## Test plan

1. Added additional tests for this use case
2. Existing tests still pass
2026-04-29 14:20:11 +02:00
..
@tailwindcss-browser Bump dependencies (#19957) 2026-04-24 21:21:12 +02:00
@tailwindcss-cli Bump dependencies (#19957) 2026-04-24 21:21:12 +02:00
@tailwindcss-node Bump dependencies (#19957) 2026-04-24 21:21:12 +02:00
@tailwindcss-postcss Fall back to the plugin base when PostCSS has no from option (#19980) 2026-04-26 13:45:39 +00:00
@tailwindcss-standalone Bump dependencies (#19957) 2026-04-24 21:21:12 +02:00
@tailwindcss-upgrade Bump dependencies (#19957) 2026-04-24 21:21:12 +02:00
@tailwindcss-vite fix(@tailwindcss/vite): include @variant in feature detection (#19966) 2026-04-24 14:11:48 +00:00
@tailwindcss-webpack Bump dependencies (#19957) 2026-04-24 21:21:12 +02:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Canonicalization: migrate [&:has(…)] to has-[…] variant (#19991) 2026-04-29 14:20:11 +02:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00