Re: [csswg-drafts] [cascade-6] Unclear proximity for scoped descendant combinator (#8380)

If we do with plain 'syntax sugar', I think you would basically treat each mention of `>>` as a nesting of scopes. That probably answers the question for examples 2 and 3, but not for example 1 – because there is no logic for `@scope` to exist inside a pseudo-class, and so no clear way to desugar it. The others, I would expect to be:

2. `A >> B C >> D` -> `@scope (A) { @scope (B C) { D }`
3. `A >> :is(B C) >> D` -> `@scope (A) { @scope (:is(B C)) { D }` (I think in practice, the scope-start parameter already acts like `:is()`, so this might be redundant)

To highlight the two questions raised here:

**Nesting Scopes, Generally**:

To make sure I understand what's implemented: When `@scope` rules are nested, you're not currently calculating all the proximity relationships up the chain - only the final relationship. You get a single number by asking: 'how close is the final matched element to the nearest scope root?' Since scopes can only contract, never expand, we know that the nearest `@scope` rule will give us the nearest scope root as well. 

I think that might be a reasonable solution, and certainly the easiest one to reason about. If we wanted, I think there might be ways to expand that and give some priority to things that are 'scoped more often' – but I'm not sure that's helpful, or actually captures a useful heuristic. But that probably needs more clarity in the specification. 

**Sugaring Limits**:

It seems like the other issue here is that a scope-start clause in the `@scope` rule has some limitations that a normal combinator does not: you can't put `@scope` inside a pseudo-class, for example. In order for the syntax sugar to be a strict subset of the `@scope` feature, it would also have to be disallowed in those situations. I think we _could_ make that limitation on either the old selector syntax or the combinators – but both have a chance of adding confusion (especially when combined with nesting).

(I'd be tempted to drop any scope selector sugar from v1 of the spec, and return later to see if it's necessary)

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


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

Received on Wednesday, 1 February 2023 22:33:59 UTC