From ad7a74f0c7d7c4aaa0aef97597b8d354326be983 Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Mon, 13 Jun 2022 10:22:03 +0200 Subject: [PATCH 1/5] add tests for spaced around operators in CSS math functions --- tests/normalize-data-types.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/normalize-data-types.test.js b/tests/normalize-data-types.test.js index d223f92eebe8..03772e7e5a08 100644 --- a/tests/normalize-data-types.test.js +++ b/tests/normalize-data-types.test.js @@ -20,7 +20,7 @@ let table = [ ['var(--foo)', 'var(--foo)'], ['var(--headings-h1-size)', 'var(--headings-h1-size)'], - // calc(…) get's spaces around operators + // math functions like calc(…) get spaces around operators ['calc(1+2)', 'calc(1 + 2)'], ['calc(100%+1rem)', 'calc(100% + 1rem)'], ['calc(1+calc(100%-20px))', 'calc(1 + calc(100% - 20px))'], @@ -29,6 +29,9 @@ let table = [ 'calc(var(--headings-h1-size)*calc(100%+50%))', 'calc(var(--headings-h1-size) * calc(100% + 50%))', ], + ['min(1+2)', 'min(1 + 2)'], + ['max(1+2)', 'max(1 + 2)'], + ['clamp(1+2,1+3,1+4)', 'clamp(1 + 2,1 + 3,1 + 4)'], ['var(--heading-h1-font-size)', 'var(--heading-h1-font-size)'], ['var(--my-var-with-more-than-3-words)', 'var(--my-var-with-more-than-3-words)'], ['var(--width, calc(100%+1rem))', 'var(--width, calc(100% + 1rem))'], From 81c6f128cf39afa4e6f9d9c94ef5734c86ad80a4 Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Mon, 13 Jun 2022 10:22:39 +0200 Subject: [PATCH 2/5] fix CSS math functons besides calc not getting the love they deserve --- src/util/dataTypes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/dataTypes.js b/src/util/dataTypes.js index 04a5ee901aa7..23a8f65caa87 100644 --- a/src/util/dataTypes.js +++ b/src/util/dataTypes.js @@ -40,9 +40,9 @@ export function normalize(value, isRoot = true) { value = value.trim() } - // Add spaces around operators inside calc() that do not follow an operator + // Add spaces around operators inside math functions calc() that do not follow an operator // or '('. - value = value.replace(/calc\(.+\)/g, (match) => { + value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => { return match.replace( /(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ' From d4810368479707eede4049d87126fc8068086fea Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Mon, 13 Jun 2022 10:24:42 +0200 Subject: [PATCH 3/5] improve comment --- src/util/dataTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/dataTypes.js b/src/util/dataTypes.js index 23a8f65caa87..8ad06654b8a6 100644 --- a/src/util/dataTypes.js +++ b/src/util/dataTypes.js @@ -40,7 +40,7 @@ export function normalize(value, isRoot = true) { value = value.trim() } - // Add spaces around operators inside math functions calc() that do not follow an operator + // Add spaces around operators inside math functions like calc() that do not follow an operator // or '('. value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => { return match.replace( From 836b6dba1c326d338ad4c584d41940d3e92f7502 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 13 Jun 2022 11:52:49 +0200 Subject: [PATCH 4/5] update changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f379785715dc..264e22e8ca81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Fix extraction of multi-word utilities with arbitrary values and quotes ([#8604](https://github.com/tailwindlabs/tailwindcss/pull/8604)) -- Fix casing of import of `corePluginList` type definition ([#8587](https://github.com/tailwindlabs/tailwindcss/pull/8587)) -- Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608)) +### Fixed + +- Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615)) ## [3.1.2] - 2022-06-10 From ac4040ee35e540c9287e1b6947896d8e7a2f22f2 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 13 Jun 2022 11:53:49 +0200 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 264e22e8ca81..ab01faec12eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fix extraction of multi-word utilities with arbitrary values and quotes ([#8604](https://github.com/tailwindlabs/tailwindcss/pull/8604)) +- Fix casing of import of `corePluginList` type definition ([#8587](https://github.com/tailwindlabs/tailwindcss/pull/8587)) +- Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608)) - Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615)) ## [3.1.2] - 2022-06-10