Re: [csswg-drafts] [css-cascade-5] Do conditional rules impact layer order? (#6407)

To summarize all of the options, and their implications:

1. Parse error – `@layer` inside a conditional is ignored, along with all nested styles. I don't think this is viable, since adding `media="screen"` to a stylesheet could turn the entire file into one large parse error.
2. Never contribute - `@layer` works inside conditionals, but without contributing to layer order. Again, I don't think this is viable, for similar reasons. We would also have to determine how layers are ordered if they _only_ appear inside conditions. Would that be a parse error?
3. Always contribute - When we say `@layer` statements are ranked in order of first appearance, we mean it, even if that appearance happens inside a conditional. From an author perspective, it is as though the layers "bubble up" to the top level. While this is mostly stable, it is possible for some styles to lazy-load (especially when using unmatched media attributes), so there are cases where a late-loading stylesheet could change the order of layers dynamically.
4. Fully dynamic - `@layer` rules inside conditional rules only apply to layer order when the condition is met. This matches the behavior of lazy-loading stylesheets based on the media attribute, but would add a lot more potentially dynamic layer re-ordering based on media changes. Since `@container` conditions have no global value, but evaluate for individual elements, we would need a special case (option 1 or 2?) for handling layers inside container queries. 

-- 
GitHub Notification of comment by mirisuzanne
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6407#issuecomment-871528258 using your GitHub account


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

Received on Wednesday, 30 June 2021 15:59:26 UTC