Re: [csswg-drafts] [css-nesting-1] Syntax Invites Errors (#7834)

> I think it is also important to challenge the opinions that sparked this.
> 
> > selectors within nested context are incompatible with those outside of nested context, and with syntax within @scope, which invites a lot of copy-paste errors when transferring code among these contexts
> 
> This is not solved by this syntax change. It can only be resolved by giving `&` meaning everywhere. (that is why there is : #5745)

That only solves it one way: you can then paste *from* a nested context to `@scope` or non-scoped contexts, but you cannot paste from `@scope` into a nested context.

> The only selectors that can omit `&` are those that use a descendant combinator.
> 
> `& .foo` -> `.foo`
> 
> But not all these :
> 
> * `&.foo`
> * `& + .foo`
> * `& > .foo`
> * `& ~ .foo`
> 

Nope, under this proposal [`<relative-selector>`](https://drafts.csswg.org/selectors/#typedef-relative-selector), i.e. `+ .foo`, `> .foo` or `~ .foo` will be perfectly valid. 

> > &.foo and & .foo are easily confusable (both for reading and for typing), and so long as the latter is required for nested relative selectors this will be a commonly encountered problem
> 
> The same is true for `.foo&` vs. `.foo &`. How does this proposal help in that case?

Both `.foo&` and `.foo &` are far rarer than `& .foo` and `&.foo` which are some of the most common nested selectors.
Also, I'm having trouble following this logic. If something is confusing it justifies something else being confusing?

> I am really trying to see the upsides of this proposal and have begon working on some sample code that compares certain aspects. Doing this so that I can get a feel for this version of nesting. [romainmenke/nesting-proposal-changes-7834](https://github.com/romainmenke/nesting-proposal-changes-7834)

This sample code demonstrates my earlier point that for a lot of code, no non-optional ampersands will even  need to be included.

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


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

Received on Thursday, 6 October 2022 18:16:34 UTC