- From: Sean Hogan <shogun70@westnet.com.au>
- Date: Mon, 11 Jan 2010 17:24:17 +1100
- To: Boris Zbarsky <bzbarsky@MIT.EDU>
- CC: Lachlan Hunt <lachlan.hunt@lachy.id.au>, public-webapps <public-webapps@w3.org>
On 11/01/10 4:19 PM, Boris Zbarsky wrote: > On 1/10/10 11:58 PM, Sean Hogan wrote: >> Even if jQuery deprecates non-standard selectors, the current spec for >> queryScopedSelector*() doesn't support the jQuery implicitly "scoped" >> selector "> *". > > As I understand it, jquery selectors on elements are always scoped in > the sense that they behave differently from the v1 Selectors API. In > particular, if I understand correctly, the behavior of: > > element.querySelector("body div") > > in matching all <div>s that are descendants of |element| and also > descendants of a <body> (which may be an _ancestor_ of |element|) is > different from the selector behavior in jquery. > > Or did I understand incorrectly? That's correct. jQuery's $(element).find("div") is the equivalent of SelectorsAPI2's element.querySelectorAll(":scope div") or element.queryScopedSelectorAll("div"). My point is that jQuery's $(element).find("> div") isn't supported (without pre-processing by the JS lib) by element.queryScopedSelectorAll(). > > All that said, I just read the draft at > http://dev.w3.org/2006/webapi/selectors-api2/ and I can't make heads > or tails of either what the new arguments to querySelector(All) are > supposed to mean (are they just an enumaration of the things :scope is > allowed to match during the selector evaluation?) or what > queryScopedSelector(All) is supposed to do. Am I just missing > something? Am I reading the wrong draft? > > (I'd link to the "dated" version of the draft, in case it changes, but > that link is broken, sadly.) > You are correct about the new refNodes argument in querySelector*(). queryScopedSelector*() are more-or-less wrappers around querySelector*(). e.g. element.queryScopedSelectorAll("div") generally becomes element.parentNode.querySelectorAll(":scope div", element) which is the same as element.querySelectorAll(":scope div", element) or even element.querySelectorAll(":scope div") element.queryScopedSelectorAll(":scope > div") generally becomes element.parentNode.querySelectorAll(":scope > div", element) which is the same as element.querySelectorAll(":scope > div", element) or even element.querySelectorAll(":scope > div") element.queryScopedSelectorAll(":scope + div") generally becomes element.parentNode.querySelectorAll(":scope + div", element) element.queryScopedSelectorAll("div, div:scope") generally becomes element.parentNode.querySelectorAll(":scope div, div:scope", element)
Received on Monday, 11 January 2010 06:25:06 UTC