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

So `elem.querySelector('...')` is defined in https://dom.spec.whatwg.org/#dom-parentnode-queryselector, it runs [scope-match a selectors string](https://dom.spec.whatwg.org/#scope-match-a-selectors-string) `'...'` against `elem`. This basically sets `elem` as the scoping root when matching.

And since the `:scope` elements are not explicitly specified, but the selector is scoped and the scoping root is the element `elem`, then `elem` matches `:scope` (and nothing else matches).

It's basically the same for `querySelectorAll`: https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall

For [`matches`](https://dom.spec.whatwg.org/#dom-element-matches), the element is used as the `:scope` element but not as the scoping root.

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5712#issuecomment-724979329 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 21:32:26 UTC