- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Thu, 16 Feb 2023 19:00:10 +0000
- To: public-css-archive@w3.org
[Rune's reading](https://github.com/w3c/csswg-drafts/issues/7261#issuecomment-1121340655): > Reading the Selectors4 spec, it looks to me that :scope always matches a true element, even if the scoping root can be a Document or a DocumentFragment/ShadowRoot? Am I reading it correctly? Was just wrong. :scope can match a virtual scoping root, like a DocumentFragment; my #6399 edits reworded the relevant text but maintained this fact. A virtual scoping root can't be the *subject of a selector*, but that just means that `docfrag.querySelector(":scope")` won't return anything; it can still match the non-element DocumentFragment node so long as it then moves the subject to an actual element (or pseudo-element). The relevant question for `Document.querySelector()` and `DocumentFragment.querySelector()` is just whether they pass a "scoping root" to the "match a selector" algorithm. [Per DOM](https://dom.spec.whatwg.org/#dom-parentnode-queryselector), it appears they do in both cases (since Document, DocumentFragment, and Element all share the same algorithm via the ParentNode mixin). So following the specs as they are written today, `document.querySelector(":scope > *")` should return the `html` element, just as `myshadowroot.querySelector(":scope > *")` returns all the root nodes in the shadow tree. -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7261#issuecomment-1433574093 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 16 February 2023 19:00:12 UTC