Repository navigation
Commit 1bea2b0
Allow spaces in the arguments of a CSS mixin in
## Summary
`@apply` with a CSS mixin threw "You cannot use `@apply` with both
mixins and utilities" as soon as the mixin arguments had a space, e.g.
`@apply --card(red, 2rem)`. The params were split on every whitespace,
so `--card(red,` was seen as a mixin and `2rem)` as a utility.
The params are now split with `segment`, so whitespace inside parens,
brackets, braces and strings is kept in the same part. The dependency
scan and the circular dependency check use the same split, so a mixin
argument like `card` in `@utility card { @apply --card({ red, card },
2rem); }` is not read as a utility. A list of valid utilities splits the
same way as before.
Fixes #20724
## Test plan
- Added `@apply --my-mixin-1(red, 2rem)` and `@apply --my-mixin-1({ 1px,
2px }, 3px)` to the existing "should be usable with CSS mixins" test in
`index.test.ts`. It fails without this change and passes with it.
- Added a test with `@apply --card({ red, card }, 2rem)` inside
`@utility card`. It fails with a circular dependency error without this
change.
- `pnpm vitest run` in `packages/tailwindcss`: all tests pass.
- `pnpm changelog check` passes.
---------
Co-authored-by: Robin Malfait <robin.malfait@shopify.com>@apply (#20725)1 parent 603cc8d commit 1bea2b0
3 files changed
Lines changed: 98 additions & 15 deletions
File tree
- .changelog
- packages/tailwindcss/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
| 105 | + | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| |||
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
165 | 163 | | |
166 | 164 | | |
167 | 165 | | |
168 | 166 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
179 | 172 | | |
180 | 173 | | |
181 | | - | |
| 174 | + | |
182 | 175 | | |
183 | 176 | | |
184 | 177 | | |
| |||
342 | 335 | | |
343 | 336 | | |
344 | 337 | | |
345 | | - | |
| 338 | + | |
346 | 339 | | |
347 | 340 | | |
348 | 341 | | |
| |||
361 | 354 | | |
362 | 355 | | |
363 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
898 | 898 | | |
899 | 899 | | |
900 | 900 | | |
| 901 | + | |
| 902 | + | |
901 | 903 | | |
902 | 904 | | |
903 | 905 | | |
| |||
912 | 914 | | |
913 | 915 | | |
914 | 916 | | |
| 917 | + | |
| 918 | + | |
915 | 919 | | |
916 | 920 | | |
917 | 921 | | |
| |||
920 | 924 | | |
921 | 925 | | |
922 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
923 | 948 | | |
924 | 949 | | |
925 | 950 | | |
| |||
940 | 965 | | |
941 | 966 | | |
942 | 967 | | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
943 | 1001 | | |
944 | 1002 | | |
945 | 1003 | | |
| |||
0 commit comments