Re: [csswg-drafts] [css-conditional-5][css-nesting-1] Feature detection for nesting (#8399)

> <fantasai> plinss: I believe it's very important that we have a stable and reliable mechanism before we ship anything, can we agree on that
> <fantasai> TabAtkins: I think it's a good idea, I'm not going to commit to it
> <fantasai> plinss: I think shipping this whithout reliable feature detection is a huge mistake

I totally agree with @plinss here. I fear, Google's strategy for shipping nesting without proper support for feature detection will have negative effects. Without a proper mechanism for feature detection, nesting is doomed to either not being adopted or to cause pages to break.

As @romainmenke [pointed out earlier](https://github.com/w3c/csswg-drafts/issues/8399#issuecomment-1418273286), the main issue is that browsers never implemented `@import "..." supports();`. Without that, authors don't have a global switch for browsers _with_ nesting support and those without. And nesting support can only be checked when wrapping specific rules in `@supports selector(&) { ... }` within a stylesheet.
Unfortunately, using `@supports` in this case mainly means unnecessarily bloating the stylesheet because authors have to provide the same rules twice for browsers with and without support. I.e. they have to wrap every nested rule in `@supports selector(&) { ... }`. And for browsers that don't support nesting they need to add another `@supports not selector(&) { ... }` section basically duplicating their rules.

@bramus

> In practice, though, I don’t think authors will test nesting, as they’ll simply see the nested styles not get applied in that case:
> 
>     * Build a base style layer that doesn’t use nesting
> 
>     * Layer nested styles on top

As outlined above, layering nested styles on top of not nested ones is not really a use case. Authors normally want to apply the same rules independently of how they are written.

Coming back to the issue outlined by @romainmenke, I believe, the main issue is allowing nesting while being backwards compatible _and_ avoid putting the burden onto users.
That means, we need a way for UAs that support nesting to somehow _suppress_ importing external stylesheets. Only when that's possible, nesting can really be used by authors without disadvantages.

Sebastian

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


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

Received on Saturday, 8 April 2023 22:03:55 UTC