Skip to content

Commit 97da59f

Browse files
Increase specificity of * and ** variants (#14920)
Increase the specificity of the `*` and `**` variants. This will now use `:is(…)` instead of `:where(…)`. In Tailwind CSS v3 we used `& > *` instead of `:where(& > *)` which means that this isn't a breaking change anymore. This also allows us to use codemod things like `[&>[data-visible]]:flex` and `[&_[data-visible]]:flex` to `*:data-visible:flex` and `**:data-visible:flex` respectively. --------- Co-authored-by: Adam Wathan <[email protected]>
1 parent 192109b commit 97da59f

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5656
- Rename `--transition-timing-function-*` variables to `--ease-*` ([#14886](https://github.com/tailwindlabs/tailwindcss/pull/14886))
5757
- Rename `--width-*` variables to `--container-*` ([#14898](https://github.com/tailwindlabs/tailwindcss/pull/14898))
5858
- Rename `--font-size-*` variables to `--text-*` ([#14909](https://github.com/tailwindlabs/tailwindcss/pull/14909))
59+
- Revert specificity of `*` variant to match v3 behavior ([#14920](https://github.com/tailwindlabs/tailwindcss/pull/14920))
5960

6061
## [4.0.0-alpha.31] - 2024-10-29
6162

packages/tailwindcss/src/variants.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('force', async () => {
1717

1818
test('*', async () => {
1919
expect(await run(['*:flex'])).toMatchInlineSnapshot(`
20-
":where(.\\*\\:flex > *) {
20+
":is(.\\*\\:flex > *) {
2121
display: flex;
2222
}"
2323
`)
@@ -26,7 +26,7 @@ test('*', async () => {
2626

2727
test('**', async () => {
2828
expect(await run(['**:flex'])).toMatchInlineSnapshot(`
29-
":where(.\\*\\*\\:flex *) {
29+
":is(.\\*\\*\\:flex *) {
3030
display: flex;
3131
}"
3232
`)

packages/tailwindcss/src/variants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ export function createVariants(theme: Theme): Variants {
363363
}
364364

365365
variants.static('force', () => {}, { compounds: Compounds.Never })
366-
staticVariant('*', [':where(& > *)'], { compounds: Compounds.Never })
367-
staticVariant('**', [':where(& *)'], { compounds: Compounds.Never })
366+
staticVariant('*', [':is(& > *)'], { compounds: Compounds.Never })
367+
staticVariant('**', [':is(& *)'], { compounds: Compounds.Never })
368368

369369
function negateConditions(ruleName: string, conditions: string[]) {
370370
return conditions.map((condition) => {

0 commit comments

Comments
 (0)