Skip to content

Commit b6d5eca

Browse files
committed
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 9db2d68 commit b6d5eca

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Don’t add spaces to negative numbers following a comma ([#12324](https://github.com/tailwindlabs/tailwindcss/pull/12324))
13+
1014
## [3.3.5] - 2023-10-25
1115

1216
### Fixed

src/util/dataTypes.js

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

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

tests/normalize-data-types.test.js

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

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

0 commit comments

Comments
 (0)