W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2009

Re: [selectors-api] Scoped Queries

From: John Resig <jresig@mozilla.com>
Date: Wed, 23 Sep 2009 23:22:22 -0400
Message-ID: <730bab940909232022u7b9b5e63t6f6004cf53c77bc@mail.gmail.com>
To: Sean Hogan <shogun70@westnet.com.au>
Cc: Jonas Sicking <jonas@sicking.cc>, Lachlan Hunt <lachlan.hunt@lachy.id.au>, public-webapps <public-webapps@w3.org>, "L. David Baron" <dbaron@mozilla.com>
> 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
Received on Thursday, 24 September 2009 03:23:21 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:33 GMT