W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

Re: QSA, the problem with ":scope", and naming

From: Jonas Sicking <jonas@sicking.cc>
Date: Fri, 21 Oct 2011 00:41:53 -0700
Message-ID: <CA+c2ei-ApF9jnY9Vr4gE3NWuzTF2GJzB_k-oVdOPie+yjpHWaA@mail.gmail.com>
To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Boris Zbarsky <bzbarsky@mit.edu>, Ojan Vafai <ojan@chromium.org>, Alex Russell <slightlyoff@google.com>, Webapps WG <public-webapps@w3.org>, Yehuda Katz <wycats@gmail.com>, John Resig <jeresig@gmail.com>, Paul Irish <paulirish@google.com>
On Thu, Oct 20, 2011 at 2:33 PM, Lachlan Hunt <lachlan.hunt@lachy.id.au>
wrote:
> Not necessarily.  It depends what exactly it means for a selector to
contain
> :scope for determining whether or not to enable the implied :scope
> behaviour.  Consider:
>
>  foo.find(":not(:scope)");

Ooh, this is an interesting case too. So here's the full list of cases which
we need defined behavior for (again looking at Alex and Yehuda here).

In the following DOM

<body id="3">
 <div id=0></div>
 <div id="context" foo=bar>
  <div id=1></div>
  <div class="class" id=2></div>
  <div class="withChildren" id=3><div class=child id=4></div></div>
 </div>
 <div id=5></div>
 <div id=6></div>
</body>

What would each of the following .findAll calls return. I've included my
guessed based on the discussions so far:

var e = document.getElementById('context');

e.findAll("div")  // returns ids 1,2,3,4
e.findAll("")      // returns an empty list
e.findAll("#3")  // returns id 3, but not the body node
e.findAll("> div") // returns ids 1,2,3
e.findAll("[foo=bar]") // returns nothing
e.findAll("[id=1]") // returns id 1
e.findAll(":first-child") // returns id 1
e.findAll("+ div") // returns id 5
e.findAll("~ div") // returns id 5, 6
e.findAll(":scope")
e.findAll("div:scope")
e.findAll("[foo=bar]:scope")
e.findAll(":scope div")
e.findAll("div:scope div")
e.findAll("div:scope #3")
e.findAll("body > :scope > div")
e.findAll("div, :scope")
e.findAll("body > :scope > div, :scope")
e.findAll(":not(:scope)")

/ Jonas
Received on Friday, 21 October 2011 07:42:33 GMT

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