Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add canonicalize utilities with 0 test
This will rely on 2 things:

1. That we properly constant fold length units into `0`
2. That we prefer the "positive" version (`mt-0`) over its negative version (`-mt-0`)
  • Loading branch information
RobinMalfait committed Oct 9, 2025
commit f12a87905e81b7009bd112ab926876c37bcf5bd9
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
//
// This translation is actually fine, because now, we will prefer the
// non-negative version first so we can replace `-mt-[0px]` with `mt-[0px]`.
['mt-[0px]', 'mt-[0px]'],
['-mt-[0px]', 'mt-[0px]'],
['mt-[0px]', 'mt-0'],
['-mt-[0px]', 'mt-0'],

// Shorthand CSS Variables should be converted to the new syntax, even if
// the fallback contains functions. The fallback should also be migrated to
Expand Down
17 changes: 17 additions & 0 deletions packages/tailwindcss/src/canonicalize-candidates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,23 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
['grid-cols-[subgrid]', 'grid-cols-subgrid'],
['grid-rows-[subgrid]', 'grid-rows-subgrid'],

// Handle zeroes
['m-[0]', 'm-0'],
['m-[0px]', 'm-0'],
['m-[0rem]', 'm-0'],

['-m-[0]', 'm-0'],
['-m-[0px]', 'm-0'],
['-m-[0rem]', 'm-0'],

['m-[-0]', 'm-0'],
['m-[-0px]', 'm-0'],
['m-[-0rem]', 'm-0'],

['-m-[-0]', 'm-0'],
['-m-[-0px]', 'm-0'],
['-m-[-0rem]', 'm-0'],

// Only 50-200% (inclusive) are valid:
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch#percentage
['font-stretch-[50%]', 'font-stretch-50%'],
Expand Down