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 b52a78b commit 47107be
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))

### Added

Expand Down
12 changes: 12 additions & 0 deletions src/util/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,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 @@ -162,6 +169,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 @@ -86,6 +86,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 47107be

Please sign in to comment.