You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In particular, I find it hard to follow what is meant by scoping root vs. :scope elements in the absence of examples pointing out which is which, in something like elem.querySelector('...').
I'd love to provide more detailed suggestions on the content of the two sections, but I feel I need a mental model of what's meant in them. Could someone explain, in layman's terms, what a scoping root and a :scope element are for the commonplace DOM methods (matches/querySelector/querySelectorAll)? (I can offer my confused interpretation of things, but I doubt that would help at this point).
The text was updated successfully, but these errors were encountered:
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).
@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? Edit: Or did I get the meaning totally wrong, and querySelectorAll() is meant as an analogy for providing a reference point to match selectors against?
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'm having a bit of a hard time understanding the terminology in CSS Selectors Level 4 regarding scoped selectors:
:scope
In particular, I find it hard to follow what is meant by scoping root vs. :scope elements in the absence of examples pointing out which is which, in something like
elem.querySelector('...')
.I'd love to provide more detailed suggestions on the content of the two sections, but I feel I need a mental model of what's meant in them. Could someone explain, in layman's terms, what a scoping root and a :scope element are for the commonplace DOM methods (matches/querySelector/querySelectorAll)? (I can offer my confused interpretation of things, but I doubt that would help at this point).
The text was updated successfully, but these errors were encountered: