Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Discard candidates with an empty data type ([#19172](https://github.com/tailwindlabs/tailwindcss/pull/19172))
- Fix canonicalization of arbitrary variants with attribute selectors ([#19176](https://github.com/tailwindlabs/tailwindcss/pull/19176))

## [4.1.15] - 2025-10-20

Expand Down
4 changes: 4 additions & 0 deletions packages/tailwindcss/src/canonicalize-candidates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,10 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
['[&_>_[data-visible]]:flex', '*:data-visible:flex'],
['[&>*]:flex', '*:flex'],
['[&_>_*]:flex', '*:flex'],
['[&_>_[foo]]:flex', '*:[[foo]]:flex'],
['[&_[foo]]:flex', '**:[[foo]]:flex'],
['[&_>_[foo=bar]]:flex', '*:[[foo=bar]]:flex'],
['[&_[foo=bar]]:flex', '**:[[foo=bar]]:flex'],

['[&_[data-visible]]:flex', '**:data-visible:flex'],
['[&_*]:flex', '**:flex'],
Expand Down
12 changes: 11 additions & 1 deletion packages/tailwindcss/src/canonicalize-candidates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1649,8 +1649,9 @@ function modernizeArbitraryValuesVariant(
!isSingleSelector(target.nodes) ||
// [foo][bar] is considered a single selector but has multiple nodes
target.nodes.length !== 1
)
) {
continue
}

// Expecting a single attribute selector
if (!isAttributeSelector(target.nodes[0])) continue
Expand Down Expand Up @@ -1796,6 +1797,15 @@ function modernizeArbitraryValuesVariant(
}, // aria-[foo~="true"], aria-[foo|="true"], …
} satisfies Variant)
}

// Arbitrary attributes
else {
replaceObject(variant, {
kind: 'arbitrary',
selector: target.value,
relative: false,
} satisfies Variant)
}
}

if (prefixedVariant) {
Expand Down