W3C home > Mailing lists > Public > public-css-archive@w3.org > November 2020

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

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Tue, 10 Nov 2020 21:32:24 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-724979329-1605043943-sysbot+gh@w3.org>
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

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:22 UTC