tailwindcss/packages
Robin Malfait f302fce815
Fix canonicalization resulting in empty list (#19812)
This PR fixes a bug in the canonicalization process where if a few
utilities collapse into a smaller one, and the smaller one is part of
the original list, then it results in an empty list.

It will be more clear with an example. Let's say you have this setup:
```
w-[calc(1rem+0.25rem)] h-[calc(1rem+0.25rem)] size-5
```

The first step is that this will result in:
```
w-5 h-5 size-5
```

Then the `w-5 h-5` can turn into `size-5`. But the existing `size-5`,
can also be replaced by the `size-5`.

Internally, when we have a replacement, then we mark all the classes
that can be replaced as "droppable", so they would be dropped from the
list. But in this scenario we also marked `size-5` as droppable,
resulting in an empty list.

If an additional class existed:
```
w-[calc(1rem+0.25rem)] h-[calc(1rem+0.25rem)] size-5 flex
```

The result would be 
```
flex
```

Instead of the expected:
```
size-5 flex
```


## Test plan

1. Existing tests pass
2. Added new tests with and without an additional class
2026-03-17 13:00:31 +01:00
..
@tailwindcss-browser 4.2.1 (#19714) 2026-02-23 11:45:12 +01:00
@tailwindcss-cli Add --stream flag to canonicalize subcommand (#19796) 2026-03-16 15:00:11 +00:00
@tailwindcss-node Cleanup inconsistencies related to (regex) escapes (#19804) 2026-03-15 22:04:58 +01:00
@tailwindcss-postcss Cleanup inconsistencies related to (regex) escapes (#19804) 2026-03-15 22:04:58 +01:00
@tailwindcss-standalone 4.2.1 (#19714) 2026-02-23 11:45:12 +01:00
@tailwindcss-upgrade fix: remove unused braces dependencies (#19797) 2026-03-15 21:10:54 +00:00
@tailwindcss-vite Cleanup inconsistencies related to (regex) escapes (#19804) 2026-03-15 22:04:58 +01:00
@tailwindcss-webpack 4.2.1 (#19714) 2026-02-23 11:45:12 +01:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Fix canonicalization resulting in empty list (#19812) 2026-03-17 13:00:31 +01:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00