Skip to content

Commit

Permalink
Don't add spaces to gradients and grid track names when followed by `…
Browse files Browse the repository at this point in the history
…calc()` (#12704)

* Don’t break gradient functions when following `calc()`

* Don’t break CSS grid track names

* Update changelog
  • Loading branch information
thecrypticace committed Jan 3, 2024
1 parent 08a0a6c commit 78fedd5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Don't remove keyframe stops when using important utilities ([#12639](https://github.com/tailwindlabs/tailwindcss/pull/12639))
- Don't add spaces to gradients and grid track names when followed by `calc()` ([#12704](https://github.com/tailwindlabs/tailwindcss/pull/12704))

## [3.4.0] - 2023-12-19

Expand Down
12 changes: 12 additions & 0 deletions src/util/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ function normalizeMathOperatorSpacing(value) {
'keyboard-inset-left',
'keyboard-inset-width',
'keyboard-inset-height',

'radial-gradient',
'linear-gradient',
'conic-gradient',
'repeating-radial-gradient',
'repeating-linear-gradient',
'repeating-conic-gradient',
]

return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
Expand Down Expand Up @@ -161,6 +168,11 @@ function normalizeMathOperatorSpacing(value) {
result += consumeUntil([')'])
}

// Don't break CSS grid track names
else if (peek('[')) {
result += consumeUntil([']'])
}

// Handle operators
else if (
['+', '-', '*', '/'].includes(char) &&
Expand Down
10 changes: 10 additions & 0 deletions tests/normalize-data-types.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ let table = [
// Prevent formatting keywords
['minmax(min-content,25%)', 'minmax(min-content,25%)'],

// Prevent formatting keywords
[
'radial-gradient(calc(1+2)),radial-gradient(calc(1+2))',
'radial-gradient(calc(1 + 2)),radial-gradient(calc(1 + 2))',
],
[
'[content-start]_calc(100%-1px)_[content-end]_minmax(1rem,1fr)',
'[content-start] calc(100% - 1px) [content-end] minmax(1rem,1fr)',
],

// Misc
['color(0_0_0/1.0)', 'color(0 0 0/1.0)'],
['color(0_0_0_/_1.0)', 'color(0 0 0 / 1.0)'],
Expand Down

0 comments on commit 78fedd5

Please sign in to comment.