Skip to content

Commit 6d9ae82

Browse files
authored
Allow anchor-size(…) in arbitrary values (tailwindlabs#14393)
This PR fixes an issue where using `anchor-size` in arbitrary values resulted in the incorrect css. Input: `w-[calc(anchor-size(width)+8px)]` Output: ```css .w-\[calc\(anchor-size\(width\)\+8px\)\] { width: calc(anchor - size(width) + 8px); } ``` This PR fixes that, by generating the correct CSS: ```css .w-\[calc\(anchor-size\(width\)\+8px\)\] { width: calc(anchor-size(width) + 8px); } ```
1 parent f07dbff commit 6d9ae82

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/util/dataTypes.js

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ function normalizeMathOperatorSpacing(value) {
147147
'repeating-radial-gradient',
148148
'repeating-linear-gradient',
149149
'repeating-conic-gradient',
150+
151+
'anchor-size',
150152
]
151153

152154
return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {

tests/normalize-data-types.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ let table = [
9696
'[content-start] calc(100% - 1px) [content-end] minmax(1rem,1fr)',
9797
],
9898

99+
// Prevent formatting functions that are not math functions
100+
['w-[calc(anchor-size(width)+8px)]', 'w-[calc(anchor-size(width) + 8px)]'],
101+
99102
// Misc
100103
['color(0_0_0/1.0)', 'color(0 0 0/1.0)'],
101104
['color(0_0_0_/_1.0)', 'color(0 0 0 / 1.0)'],

0 commit comments

Comments
 (0)