Skip calc() normalisation in nested theme() calls (#11705)

* add `calc` normalisation test cases using `theme()`

* ignore formatting in some known functions, such as `theme`

* update changelog
This commit is contained in:
Robin Malfait 2023-07-27 17:50:58 +02:00 • committed by GitHub
parent ae4d21308d
commit a72d97cebb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View file

@ -59,6 +59,8 @@ export function normalize(value, isRoot = true) {
* @returns {string}
*/
function normalizeMathOperatorSpacing(value) {
let preventFormattingInFunctions = ['theme']
return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
let result = ''
@ -100,6 +102,11 @@ function normalizeMathOperatorSpacing(value) {
result += consumeUntil([')', ','])
}
// Skip formatting inside known functions
else if (preventFormattingInFunctions.some((fn) => peek(fn))) {
result += consumeUntil([')'])
}
// Handle operators
else if (
['+', '-', '*', '/'].includes(char) &&