Commit f036f80
## Summary
Fixes #16948
When defining multiple CSS `@utility foo-*` with different value types
(e.g., one for colors, one for numbers), only the first handler was
tried. If it returned `null` (value didn't match), the compile loop
stopped, preventing subsequent handlers from being attempted.
```css
@Utility foo-* {
color: --value(--color-*);
}
@Utility foo-* {
font-size: --spacing(--value(number));
}
```
Previously, `foo-red-500` worked but `foo-123` did not (or vice versa
depending on definition order).
The fix distinguishes between CSS `@utility` handlers and JS plugin
`matchUtilities` handlers:
- **CSS `@utility`** (no typed options): `null` means "try the next
handler" - allows multiple definitions with different value types to
coexist
- **JS `matchUtilities`** (with explicit types): `null` means "the value
was invalid for this type, stop" - preserves existing behavior where
typed utilities prevent invalid values from falling through
## Test plan
- Added test: two `@utility foo-*` definitions with different value
types - verifies both `foo-red-500` (color) and `foo-123` (number)
produce correct CSS
- All 4621 existing tests pass (including the `matchUtilities`
type-safety tests)
- `pnpm build && pnpm test` passes
This contribution was developed with AI assistance (Claude Code).
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
1 parent d194d4c commit f036f80
3 files changed
Lines changed: 61 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
291 | 303 | | |
292 | 304 | | |
293 | 305 | | |
| |||
299 | 311 | | |
300 | 312 | | |
301 | 313 | | |
302 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
303 | 327 | | |
304 | 328 | | |
305 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29979 | 29979 | | |
29980 | 29980 | | |
29981 | 29981 | | |
| 29982 | + | |
| 29983 | + | |
| 29984 | + | |
| 29985 | + | |
| 29986 | + | |
| 29987 | + | |
| 29988 | + | |
| 29989 | + | |
| 29990 | + | |
| 29991 | + | |
| 29992 | + | |
| 29993 | + | |
| 29994 | + | |
| 29995 | + | |
| 29996 | + | |
| 29997 | + | |
| 29998 | + | |
| 29999 | + | |
| 30000 | + | |
| 30001 | + | |
| 30002 | + | |
| 30003 | + | |
| 30004 | + | |
| 30005 | + | |
| 30006 | + | |
| 30007 | + | |
| 30008 | + | |
| 30009 | + | |
| 30010 | + | |
| 30011 | + | |
| 30012 | + | |
| 30013 | + | |
| 30014 | + | |
| 30015 | + | |
29982 | 30016 | | |
0 commit comments