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 @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improve canonicalizations for `tracking-*` utilities ([#19827](https://github.com/tailwindlabs/tailwindcss/pull/19827))
- Fix crash due to invalid characters in candidate ([#19829](https://github.com/tailwindlabs/tailwindcss/pull/19829))
- Ensure query params in imports are considered unique resources when using `@tailwindcss/webpack` ([#19723](https://github.com/tailwindlabs/tailwindcss/pull/19723))
- Collapse arbitrary values into shorthand utilities during canonicalization ([#19837](https://github.com/tailwindlabs/tailwindcss/pull/19837))

## [4.2.2] - 2026-03-18

Expand Down
31 changes: 31 additions & 0 deletions packages/tailwindcss/src/canonicalize-candidates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1310,3 +1310,34 @@ test(
)
},
)

// https://github.com/tailwindlabs/tailwindcss/issues/19835
test.each([
// Arbitrary values should be collapsed to another arbitrary value
[
['px-[1.2rem]', 'py-[1.2rem]', 'text-left'],
['text-left', 'p-[1.2rem]'],
],

// Arbitrary values could also be collapsed into a bare value
[
['px-[30.75rem]', 'py-[30.75rem]', 'text-left'],
['text-left', 'p-123'],
],
])(
'collapse canonicalization works for arbitrary values',
{ timeout },
async (candidates, expected) => {
let designSystem = await designSystems.get(__dirname).get(css`
@import 'tailwindcss';
`)

let options: CanonicalizeOptions = {
collapse: true,
logicalToPhysical: true,
rem: 16,
}

expect(designSystem.canonicalizeCandidates(candidates, options)).toEqual(expected)
},
)
5 changes: 1 addition & 4 deletions packages/tailwindcss/src/canonicalize-candidates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,7 @@ function collapseCandidates(options: InternalCanonicalizeOptions, candidates: st
if (relevantProperties.size === 0) return result

for (let parsedCandidate of parseCandidate(designSystem, candidate)) {
if (
parsedCandidate.kind !== 'functional' ||
parsedCandidate.value?.kind !== 'named' // Necessary for bare values
) {
if (parsedCandidate.kind !== 'functional' || parsedCandidate.value === null) {
continue
}

Expand Down