Skip to content

Commit 0985d26

Browse files
Don’t add spaces to negative numbers following a comma (#12324)
* Don’t add spaces to negative numbers following a comma * Update changelog
1 parent 8f788e2 commit 0985d26

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Improve types for `resolveConfig` ([#12272](https://github.com/tailwindlabs/tailwindcss/pull/12272))
13+
- Don’t add spaces to negative numbers following a comma ([#12324](https://github.com/tailwindlabs/tailwindcss/pull/12324))
1314
- [Oxide] Remove `autoprefixer` dependency ([#11315](https://github.com/tailwindlabs/tailwindcss/pull/11315))
1415
- [Oxide] Fix source maps issue resulting in a crash ([#11319](https://github.com/tailwindlabs/tailwindcss/pull/11319))
1516
- [Oxide] Fallback to RegEx based parser when using custom transformers or extractors ([#11335](https://github.com/tailwindlabs/tailwindcss/pull/11335))

src/util/dataTypes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function normalize(value, context = null, isRoot = true) {
7878

7979
/**
8080
* Add spaces around operators inside math functions
81-
* like calc() that do not follow an operator or '('.
81+
* like calc() that do not follow an operator, '(', or `,`.
8282
*
8383
* @param {string} value
8484
* @returns {string}
@@ -165,7 +165,7 @@ function normalizeMathOperatorSpacing(value) {
165165
// Handle operators
166166
else if (
167167
['+', '-', '*', '/'].includes(char) &&
168-
!['(', '+', '-', '*', '/'].includes(lastChar())
168+
!['(', '+', '-', '*', '/', ','].includes(lastChar())
169169
) {
170170
result += ` ${char} `
171171
} else {

tests/normalize-data-types.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ let table = [
6868
['calc(theme(spacing.foo-2))', 'calc(theme(spacing.foo-2))'],
6969
['calc(theme(spacing.foo-bar))', 'calc(theme(spacing.foo-bar))'],
7070

71+
// A negative number immediately after a `,` should not have spaces inserted
72+
['clamp(-3px+4px,-3px+4px,-3px+4px)', 'clamp(-3px + 4px,-3px + 4px,-3px + 4px)'],
73+
7174
// Prevent formatting inside `var()` functions
7275
['calc(var(--foo-bar-bar)*2)', 'calc(var(--foo-bar-bar) * 2)'],
7376

0 commit comments

Comments
 (0)