W3C home > Mailing lists > Public > public-webapi@w3.org > April 2008

Re: [SelectorsAPI] Thoughts on querySelectorAll

From: John Resig <jresig@mozilla.com>
Date: Wed, 30 Apr 2008 15:21:22 -0700 (PDT)
To: Jonas Sicking <jonas@sicking.cc>
Cc: public-webapi@w3.org
Message-ID: <21396518.17211209594082949.JavaMail.root@cm-mail02.mozilla.org>


> So am I understanding you right in that if we do provide the second 
> issue (Combinator-rooted Queries) then that will resolve your concern
> about this issue?

Not really, no - that would presume that it's obvious to prepend :root to every single one of your element-rooted queries in order to make them work.

  element.querySelectorAll(":root div span")

This goes beyond 'JavaScript libraries' in this case - it simply isn't intuitive to require extra syntax to get the right result.

> I do understand your concern that in most cases you probably don't
> want 
> the selector matching to "leak" out of the node on which 
> .querySelectorAll was called. But I think spec-wise it's easier if the
> problem can be solved by using the ":root trick" or some such. That
> way 
> the Webapi WG doesn't have to define a pile of new behavior for
> general 
> selector matching.
> 
> The added bonus of the current matching is that it does allow for the
> selector to "leak" should you want that for whatever reason.

This isn't really important since this result can already be achieved in another manner, using .compareDocumentPosition() or .contains() (in IE). However, leaving it "broken by default because it would be hard to specify" doesn't really seem to mesh well.

> The libraries out there would only need to prepend ":root " to
> whatever 
> selector they were handed.

Sure - this is fine for invalid selectors (such as combinator-rooted ones) - which is why I like that particular suggestion. However, requiring them for all plain-old element queries doesn't seem to work well.

--John
Received on Wednesday, 30 April 2008 22:22:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 April 2008 22:22:02 GMT