Re: [csswg-drafts] [css-selectors-4] Clarification needed for scoped selectors (§3.3 and §8.6) (#5712)

@Loirooriol Thank you for the reply! Just to make sure I got that, I'm going to paraphrase your explanation:

The DOM methods `Element.querySelector(s)`/`Element.querySelectorAll(s)` use their Element instance (`this`) as a _scoping root_.

_:scope elements_ is a mechanism for methods invoking the _match a selector against an element_ algorithm to override the meaning of the `:scope` selector, which would otherwise fall back to the _scoping root_, if any (`:root` if there's no scoping root). 

In contrast to `querySelector`/`querySelectorAll`, `matches()` and `closest()` don't scope their matches to `this` (most obvious for `closest`, which needs to reach up the DOM tree), but they do want `:scope` to match `this`, and not `:root`. 

If that's the case, my top suggestions (both of them IMHO):

* In §3.3, the _Note_ needlessly, and prematurely, introduces the concept of `:scope elements`. It does not clarify anything going on in §3.3 and may better be suited in §8.6 (or even made redundant by it). 
* In §8.6:
  > In some contexts, selectors can be matched with an explicit set of :scope elements. This is is a (potentially empty) set of elements that provide a reference point for selectors to match against, __such as that specified by the querySelector() call in [DOM]__.
  had introduced the confusion — the paragraph suggest `elem` in `elem.querySelector` is a _:scope element_, when in fact it's the _scoping root_. The paragraph should probably read `closest()` instead?

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


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

Received on Tuesday, 10 November 2020 22:00:18 UTC