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 @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Guard object lookups against inherited prototype properties ([#19725](https://github.com/tailwindlabs/tailwindcss/pull/19725))
- Canonicalize `calc(var(--spacing)*…)` expressions into `--spacing(…)` ([#19769](https://github.com/tailwindlabs/tailwindcss/pull/19769))
- Fix crash in canonicalization step when handling utilities with empty property maps ([#19727](https://github.com/tailwindlabs/tailwindcss/pull/19727))

## [4.2.1] - 2026-02-23

Expand Down
37 changes: 37 additions & 0 deletions packages/tailwindcss/src/canonicalize-candidates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1220,3 +1220,40 @@ test('collapse canonicalization is not affected by previous calls', { timeout },
'size-4',
])
})

test('collapse does not crash when utilities with no standard properties are present', { timeout }, async () => {
let designSystem = await designSystems.get(__dirname).get(css`
@import 'tailwindcss';
`)

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

// Shadow utilities use CSS custom properties and @property rules but may
// produce empty property maps in the collapse algorithm. This should not
// crash with "Cannot read properties of null" or "X is not iterable".
expect(() =>
designSystem.canonicalizeCandidates(['shadow-sm', 'border'], options),
).not.toThrow()

expect(() =>
designSystem.canonicalizeCandidates(['shadow-md', 'p-4'], options),
).not.toThrow()

expect(() =>
designSystem.canonicalizeCandidates(['shadow-sm', 'shadow-md'], options),
).not.toThrow()

// Verify the candidates are returned (not collapsed, since shadows can't
// meaningfully collapse with unrelated utilities)
expect(
designSystem.canonicalizeCandidates(['shadow-sm', 'border'], options),
).toEqual(expect.arrayContaining(['shadow-sm', 'border']))

expect(
designSystem.canonicalizeCandidates(['shadow-sm', 'shadow-md'], options),
).toEqual(expect.arrayContaining(['shadow-sm', 'shadow-md']))
})
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/canonicalize-candidates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ function collapseCandidates(options: InternalCanonicalizeOptions, candidates: st
// all intersections with an empty set will remain empty.
if (result!.size === 0) return result!
}
return result!
return result ?? new Set<string>()
})

// Link each candidate that could be linked via another utility
Expand Down
Loading