Skip to content

Commit

Permalink
Allow anchor-size(…) in arbitrary values (#14393)
Browse files Browse the repository at this point in the history
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);
}
```
  • Loading branch information
RobinMalfait authored Sep 11, 2024
1 parent f07dbff commit 6d9ae82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/util/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ function normalizeMathOperatorSpacing(value) {
'repeating-radial-gradient',
'repeating-linear-gradient',
'repeating-conic-gradient',

'anchor-size',
]

return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
Expand Down
3 changes: 3 additions & 0 deletions tests/normalize-data-types.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ let table = [
'[content-start] calc(100% - 1px) [content-end] minmax(1rem,1fr)',
],

// Prevent formatting functions that are not math functions
['w-[calc(anchor-size(width)+8px)]', 'w-[calc(anchor-size(width) + 8px)]'],

// Misc
['color(0_0_0/1.0)', 'color(0 0 0/1.0)'],
['color(0_0_0_/_1.0)', 'color(0 0 0 / 1.0)'],
Expand Down

0 comments on commit 6d9ae82

Please sign in to comment.