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
3 changes: 3 additions & 0 deletions .changelog/canonicalize-whitespace-only-value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- Canonicalization: keep the value of arbitrary properties that only contain whitespace (e.g. `[--foo:_]` no longer becomes `[--foo:]`)
7 changes: 6 additions & 1 deletion packages/tailwindcss/src/candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,12 @@ const printArbitraryValueCache = new DefaultMap<string, string>((input) => {
}

// Leading and trailing whitespace
else if (node.kind === 'separator' && node.value.length > 0 && node.value.trim() === '') {
else if (
node.kind === 'separator' &&
node.value.length > 0 &&
node.value.trim() === '' &&
ctx.siblings.length > 1
) {
if (ctx.siblings[0] === node || ctx.siblings[ctx.siblings.length - 1] === node) {
drop.add(node)
}
Expand Down
1 change: 1 addition & 0 deletions packages/tailwindcss/src/canonicalize-candidates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
'shadow-[inset_0px_1px_--theme(--color-white/15%)]',
'shadow-[inset_0px_1px_--theme(--color-white/15%)]',
],
['[--foo:_]', '[--foo:_]'],

// Improve readability when whitespace was used for readability
['w-[calc(100%_-_calc(var(--spacing)*60))]', 'w-[calc(100%-(--spacing(60)))]'],
Expand Down
Loading