Csswg-drafts: [selectors-4] The behaviour of :scope in DocumentFragment or ShadowRoot

Created on 14 Aug 2018  ·  1Comment  ·  Source: w3c/csswg-drafts

What should documentFragment.querySelector(":scope") return?
Since DocumentFragment is not an element, it cannot return DocumentFragment.

In the case of ShadowRoot, what should shadowRoot.querySelector(':scope > div') return?

Link to the spec section:
https://drafts.csswg.org/selectors-4/#scoping

cc @tabatkins @fantasai

Most helpful comment

No need to explicitly tag us in, we read all the issues anyway.

Your first question is "nothing" - querySelector()'s argument is a scoped selector, which only matches descendants of the scoping element.

For your second, it's defined in CSS Scoping - the shadow root is a virtual scoping root. The shadow root does have children - the elements of the shadow tree - so they're appropriately matched. If there are any top-level divs in the shadow tree, they'll be returned by that query.

>All comments

No need to explicitly tag us in, we read all the issues anyway.

Your first question is "nothing" - querySelector()'s argument is a scoped selector, which only matches descendants of the scoping element.

For your second, it's defined in CSS Scoping - the shadow root is a virtual scoping root. The shadow root does have children - the elements of the shadow tree - so they're appropriately matched. If there are any top-level divs in the shadow tree, they'll be returned by that query.

Was this page helpful?
0 / 5 - 0 ratings