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

> They should and do expect the rendered page to be fully broken.
> There is just no way around this. The vast majority of rules and declarations will be nested and thus thrown out as invalid. The way nested CSS is written today is just not compatible with older browsers.

Yes, Romain is making the right point. While an `@layer` rule in an old browser won't mess up the *following* rule, it will absolutely make your stylesheet *useless* since it'll cause the entire *contents* of the `@layer` to get thrown away. That's a huge problem! There's simply no way to get around it, tho, without *at best* doing some really awkward workarounds in the design that would significantly hamper the feature going forward.

Nesting is in exactly the same boat. Your nested rules *will simply get thrown away* in older browsers. There's no way to work around this; you have to either buy in to Nesting (accepting that your stylesheet will be broken in older browsers) or avoid it entirely. And if you're buying in, the error-recovery change doesn't matter; it'll work correctly in the browsers that your stylesheet works in, and it'll be extremely broken in older browsers *no matter what*.

This is just how adding newer syntax features works. It's happened in the past, and it'll happen in the future; Nesting is perfectly normal in this regard. It's awkward during the transition period but stops being a problem as usage numbers advance. We certainly *prefer* designing features that can gracefully fallback instead, but if sometimes isn't an option.

All that said, this *particular* issue only occurs if you put properties *after* rules, which is a bad practice anyway. Put all your properties at the top, before any rules, and you'll be fine. Putting them later gives you absolutely nothing except possible confusion.

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


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

Received on Wednesday, 25 January 2023 23:19:35 UTC