mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
## Summary Fixes #20689 Previously, `@layer` blocks were not being processed through the CSS minifier, which meant that `color-scheme` properties inside `@layer` blocks would not get the required `--buncss-light`/`--buncss-dark` variable injections needed for browsers that don't support the `light-dark()` function. ## Changes - Implemented proper minification for `LayerBlockRule` in `src/css/rules/rules.zig:218-221` - Added recursive call to `minify()` on nested rules, matching the behavior of other at-rules like `@media` and `@supports` - Added comprehensive tests for `color-scheme` inside `@layer` blocks ## Test Plan Added three new test cases in `test/js/bun/css/css.test.ts`: 1. Simple `@layer` with `color-scheme: dark` 2. Named layers (`@layer shm.colors`) with multiple rules 3. Anonymous `@layer` with `color-scheme: light dark` (generates media query) All tests pass: ```bash bun bd test test/js/bun/css/css.test.ts -t "color-scheme" ``` ## Before ```css /* Input */ @layer shm.colors { body.theme-dark { color-scheme: dark; } } /* Output (broken - no variables) */ @layer shm.colors { body.theme-dark { color-scheme: dark; } } ``` ## After ```css /* Input */ @layer shm.colors { body.theme-dark { color-scheme: dark; } } /* Output (fixed - variables injected) */ @layer shm.colors { body.theme-dark { --buncss-light: ; --buncss-dark: initial; color-scheme: dark; } } ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>