Skip to content

Commit aad299c

Browse files
Fix missing spaces around arithmetic operators (#8615)
* add tests for spaced around operators in CSS math functions * fix CSS math functons besides calc not getting the love they deserve * improve comment * update changelog * update changelog Co-authored-by: Robin Malfait <[email protected]>
1 parent d116563 commit aad299c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Diff for: CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Fixed
11+
1012
- Fix extraction of multi-word utilities with arbitrary values and quotes ([#8604](https://github.com/tailwindlabs/tailwindcss/pull/8604))
1113
- Fix casing of import of `corePluginList` type definition ([#8587](https://github.com/tailwindlabs/tailwindcss/pull/8587))
1214
- Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608))
15+
- Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615))
1316

1417
## [3.1.2] - 2022-06-10
1518

Diff for: src/util/dataTypes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export function normalize(value, isRoot = true) {
4040
value = value.trim()
4141
}
4242

43-
// Add spaces around operators inside calc() that do not follow an operator
43+
// Add spaces around operators inside math functions like calc() that do not follow an operator
4444
// or '('.
45-
value = value.replace(/calc\(.+\)/g, (match) => {
45+
value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
4646
return match.replace(
4747
/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,
4848
'$1 $2 '

Diff for: tests/normalize-data-types.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let table = [
2020
['var(--foo)', 'var(--foo)'],
2121
['var(--headings-h1-size)', 'var(--headings-h1-size)'],
2222

23-
// calc(…) get's spaces around operators
23+
// math functions like calc(…) get spaces around operators
2424
['calc(1+2)', 'calc(1 + 2)'],
2525
['calc(100%+1rem)', 'calc(100% + 1rem)'],
2626
['calc(1+calc(100%-20px))', 'calc(1 + calc(100% - 20px))'],
@@ -29,6 +29,9 @@ let table = [
2929
'calc(var(--headings-h1-size)*calc(100%+50%))',
3030
'calc(var(--headings-h1-size) * calc(100% + 50%))',
3131
],
32+
['min(1+2)', 'min(1 + 2)'],
33+
['max(1+2)', 'max(1 + 2)'],
34+
['clamp(1+2,1+3,1+4)', 'clamp(1 + 2,1 + 3,1 + 4)'],
3235
['var(--heading-h1-font-size)', 'var(--heading-h1-font-size)'],
3336
['var(--my-var-with-more-than-3-words)', 'var(--my-var-with-more-than-3-words)'],
3437
['var(--width, calc(100%+1rem))', 'var(--width, calc(100% + 1rem))'],

0 commit comments

Comments
 (0)