[csswg-drafts] [css-cascade-5] Proposal to disallow interleaving of @layer and @import rules (#6522)

xiaochengh has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-cascade-5] Proposal to disallow interleaving of @layer and @import rules ==
Regarding empty @layer statements, the current [spec](https://drafts.csswg.org/css-cascade-5/#layer-empty) says:

> Such empty @layer rules are allowed anywhere either @import or other @layer rules are allowed.

And [also](https://drafts.csswg.org/css-cascade-5/#at-import):

> Any @import rules must precede all other valid at-rules and style rules in a style sheet (ignoring @charset and empty @layer definitions), or else the @import rule is invalid.

This allows interleaving @layer and @import rules. I'm proposing to disallow it because:
- There doesn't seem to be a valid use case to interleave these two types of rules
- No interleaving makes it much easier to implement in Chromium. Otherwise, we need to maintain the relative ordering between @layer and @import rules in the [StyleSheetContents](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/css/style_sheet_contents.h;l=50;drc=068d917a72636ddbb64dfa7ecabe6bac71bd4b26;bpv=1;bpt=1) class, which makes it more complicated without getting any benefit

The exact proposal is that rules in a style sheet must follow this ordering:
1. @charset
2. Empty @layer statements
3. @import
4. @namespace
5. All other rules + empty @layer statements



Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6522 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 17 August 2021 00:43:56 UTC