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

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 UTC