parcel-bundler / parcel-bundler/lightningcss
bug: `@property` rules remain nested in selector when targeting Chrome ≥120
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7.7k
- Forks
- 302
- PR merge metrics
- No merged PRs in 30d
Description
We ran into this issue while working on @property support in next-yak. It was reported by a user migrating from emotion in DigitecGalaxus/next-yak#325
According to the CSS spec, @property rules must appear at the top level of a stylesheet.
They must not be nested inside selectors.
LightningCSS currently handles this differently depending on Chrome version:
- For Chrome ≤119:
@propertyrules are correctly hoisted to the root level Playground Link ✅ works - For Chrome ≥120:
@propertyrules incorrectly stay nested in selectors Playground Link ❌ broken
Reproduction
When a user writes:
.example {
@property --angle {
syntax: '<angle>';
inherits: true;
initial-value: 0turn;
}
animation: spin 3s linear infinite;
}
Output for Chrome ≤119 (correct):
@property --angle {
syntax: '<angle>';
inherits: true;
initial-value: 0turn;
}
.example {
animation: spin 3s linear infinite;
}
Output for Chrome ≥120 (broken):
.example {
@property --angle {
syntax: '<angle>';
inherits: true;
initial-value: 0turn;
}
animation: spin 3s linear infinite;
}
@Mad-Kat found out that in LightningCSS the CSS nesting feature being automatically disabled when targeting Chrome ≥120
Expected Behavior
@property rules should always be hoisted to the root level, regardless of target Chrome version or nesting feature status.
In Chrome's actual implementation, @property rules don't work when nested inside selectors (as seen in this CodePen example).
This means that LightningCSS generates broken CSS
If you briefly outline how this issue should be solved we can create a pull request
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading src/compat.rs around lines 1395-1410 and compare the Chrome ≤119 and ≥120 reproduction outputs. Trace how the nesting feature status affects handling of @property rules. Done means @property is hoisted to the stylesheet root for both target ranges, with the reported reproduction no longer producing nested output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, rust
- Domain
- compilers, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100