Re: [csswg-drafts] [css-nesting] Another problem with mixing declarations and rules - error recovery (#8349)

> That's not true in general. The @layer may just contain one rule with some minor styles that aren't really important to render the page well. While ignoring the entire stylesheet could have a heavy negative impact. It depends on the case.

Yes, one can imagine a scenario in which `@layer` is used, for some reason, purely for a small cosmetic effect. That is not a *realistic* usage scenario, however, so I didn't address it. We generally expect people to use `@layer` by putting *the entire stylesheet* into layers, or at least most of it.

> I can't recall a single new feature that had this effect. It's not the case for property values, property names, selectors nor at-rules. When these things are not recognized, they don't affect the next declaration or rule. The closest thing that comes to mind is selector lists, where a single invalid branch invalidates the others, but it still only affects that rule, and this behavior has caused lots of frustration.

I didn't say we'd added new parsing constructs that invalidates the next property, I said we've added features that are all-or-nothing - either you only care about browsers that support them, or you don't use the feature at all, because it's used in a wide-ranging and integral way that isn't realistically fall-back-able.

> 1st time I have seen this described as bad practice. [drafts.csswg.org/css-nesting/#mixing](https://drafts.csswg.org/css-nesting/#mixing) just says "all three can be arbitrarily mixed". If it's bad practice then the spec should warn authors.

An older version of the spec did more explicitly warn against it. Having a warning put back in is probably appropriate, just for reasons of readability.

> My point is that while stylesheets will break in older browsers, they should break in a predicable way so that anyone who wants to provide fallback behavior for older browsers can

In the (likely exceedingly rare) cases someone does want to write a stylesheet using nesting while providing some sort of content for those without, the rule is: put your properties first.

> We just spent a large part of a meeting discussing how mixed rules and properties work, and no one said "don't do that".

Right, we've said if often enough that it didn't particularly bear repeating, plus "don't do it" isn't a valid response to "what should the behavior be when someone does it". 

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


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

Received on Thursday, 26 January 2023 22:42:39 UTC