From b6d5eca5642c4d18ad150e8af2635c44ddb4fc42 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 30 Oct 2023 10:47:24 -0400 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20add=20spaces=20to=20negative=20?= =?UTF-8?q?numbers=20following=20a=20comma=20(#12324)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Don’t add spaces to negative numbers following a comma * Update changelog --- CHANGELOG.md | 4 ++++ src/util/dataTypes.js | 4 ++-- tests/normalize-data-types.test.js | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 378335207..f655b0888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Don’t add spaces to negative numbers following a comma ([#12324](https://github.com/tailwindlabs/tailwindcss/pull/12324)) + ## [3.3.5] - 2023-10-25 ### Fixed diff --git a/src/util/dataTypes.js b/src/util/dataTypes.js index 005c37ad1..06ccb9524 100644 --- a/src/util/dataTypes.js +++ b/src/util/dataTypes.js @@ -77,7 +77,7 @@ export function normalize(value, context = null, isRoot = true) { /** * Add spaces around operators inside math functions - * like calc() that do not follow an operator or '('. + * like calc() that do not follow an operator, '(', or `,`. * * @param {string} value * @returns {string} @@ -164,7 +164,7 @@ function normalizeMathOperatorSpacing(value) { // Handle operators else if ( ['+', '-', '*', '/'].includes(char) && - !['(', '+', '-', '*', '/'].includes(lastChar()) + !['(', '+', '-', '*', '/', ','].includes(lastChar()) ) { result += ` ${char} ` } else { diff --git a/tests/normalize-data-types.test.js b/tests/normalize-data-types.test.js index f11e38b79..b249f7874 100644 --- a/tests/normalize-data-types.test.js +++ b/tests/normalize-data-types.test.js @@ -69,6 +69,9 @@ let table = [ ['calc(theme(spacing.foo-2))', 'calc(theme(spacing.foo-2))'], ['calc(theme(spacing.foo-bar))', 'calc(theme(spacing.foo-bar))'], + // A negative number immediately after a `,` should not have spaces inserted + ['clamp(-3px+4px,-3px+4px,-3px+4px)', 'clamp(-3px + 4px,-3px + 4px,-3px + 4px)'], + // Prevent formatting inside `var()` functions ['calc(var(--foo-bar-bar)*2)', 'calc(var(--foo-bar-bar) * 2)'],