Files
bun.sh/test/internal/ban-limits.json
robobun 5a7b824091 fix(css): process color-scheme rules inside @layer blocks (#24034)
## 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>
2025-10-24 19:27:14 -07:00

46 lines
1.1 KiB
JSON

{
" != undefined": 0,
" == undefined": 0,
" catch bun.outOfMemory()": 0,
"!= alloc.ptr": 0,
"!= allocator.ptr": 0,
".arguments_old(": 265,
".jsBoolean(false)": 0,
".jsBoolean(true)": 0,
".stdDir()": 41,
".stdFile()": 16,
"// autofix": 164,
": [^=]+= undefined,$": 255,
"== alloc.ptr": 0,
"== allocator.ptr": 0,
"@import(\"bun\").": 0,
"EXCEPTION_ASSERT(!scope.exception())": 0,
"JSValue.false": 0,
"JSValue.true": 0,
"TODO: properly propagate exception upwards": 118,
"alloc.ptr !=": 0,
"alloc.ptr ==": 0,
"allocator.ptr !=": 1,
"allocator.ptr ==": 0,
"global.hasException": 28,
"globalObject.hasException": 47,
"globalThis.hasException": 125,
"std.StringArrayHashMap(": 1,
"std.StringArrayHashMapUnmanaged(": 11,
"std.StringHashMap(": 0,
"std.StringHashMapUnmanaged(": 0,
"std.Thread.Mutex": 1,
"std.debug.assert": 26,
"std.debug.dumpStackTrace": 0,
"std.debug.print": 0,
"std.enums.tagName(": 2,
"std.fs.Dir": 164,
"std.fs.File": 62,
"std.fs.cwd": 102,
"std.log": 1,
"std.mem.indexOfAny(u8": 0,
"std.unicode": 27,
"undefined != ": 0,
"undefined == ": 0,
"usingnamespace": 0
}