On 19/10/11 2:39 PM, Ojan Vafai wrote:
Overall, I wholeheartedly support the proposal.
I don't really see the benefit of allowing starting with a combinator.
I think it's a rare case that you actually care about the scope
element and in those cases, using :scope is fine. Instead of
element.findAll("> div > .thinger"), you use element.findAll(":scope >
div > .thinger"). That said, I don't object to considering the :scope
implied if the selector starts with a combinator.
I can think of two reasons one might ponder allowing :scope to be explicit.
1. so that the selector string can be a valid CSS selector string.
(":scope>div>.thinger" instead of ">div>.thinger"). But if this is
important then :scope should always be explicit, in which case we can
just use querySelectorAll().
2. to allow break-out behavior. e.g.
div.findAll("body div span"); // finds nothing
div.findAll("body div:scope span"); // finds span's that are descendants
of div
In this scenario, the :scope pseudo allows ancestors of div to be
matched against. (No-one would use body in this context, but it is easy
to imagine them using a .class selector which matches an ancestor of div.)
But if you want break-out behavior you might not know which part of the
selector to put the :scope pseudo on. Could it be:
body div:scope span
body *:scope div span
body div *:scope span
So for break-out behavior just use querySelectorAll().
I'm pretty sure previous discussions (before this thread) have covered
this more thoroughly, and shown that it has to be all or nothing with
the :scope pseudo-attribute. That is, either
a) :scope MUST be explicit, in which case just use querySelectorAll()
b) :scope MUST be implied at the start of every selector chain.
Sean