John Resig wrote:
Libraries already parse selector queries anyway. And some of them
add non-standard selectors and presumeably will continue to do so.
I don't think it is an issue.
However the parsing only happens after the selector has been passed to
the native querySelectorAll implementation. We assume the qSA will
provide the fastest solution. If it throws an exception we then branch
off into the old, slower, selector engine and forget qSA entirely.
Since there's no good error-reporting coming from qSA we can't,
reasonably, determine how or why an error happened (was it a syntax
error (foo<bar)? is the selector supposed to be supported but just
isn't (div:nth-of-type(2) in IE 8)? does it look like a valid selector
but there's no existing implementation (div:first)?).
If there were two solutions, one that forced you to use :scope in
front of all queries (or sub-queries) and one that had a separate
method that handled cases like "> div" properly, I'd take the latter.
Parsing queries sucks and is slow, it's easier to just pass all of
that off to the browser.
--John
Yes, it will have to be a new method.
"> div" may be unambiguously ":scope > div", but if you allow it then
people will expect "div p" to be ":scope div p"which would conflict the
current definition.