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

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

From: Alex Russell <slightlyoff@google.com>
Date: Mon, 31 Oct 2011 13:55:26 -0700
Message-ID: <CANr5HFV3v0xAYo-z2KdbiD+mB8hR3Qphz3_y2KW6W6byVoYJRQ@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Lachlan Hunt <lachlan.hunt@lachy.id.au>, "Tab Atkins Jr." <jackalmage@gmail.com>, Boris Zbarsky <bzbarsky@mit.edu>, Ojan Vafai <ojan@chromium.org>, Webapps WG <public-webapps@w3.org>, Yehuda Katz <wycats@gmail.com>, John Resig <jeresig@gmail.com>, Paul Irish <paulirish@google.com>
On Fri, Oct 21, 2011 at 12:41 AM, Jonas Sicking <jonas@sicking.cc> wrote:
> 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")

Returns the context.

> e.findAll("div:scope")

Returns the context.

> e.findAll("[foo=bar]:scope")

Returns the context.

> e.findAll(":scope div")

1, 2, 3, 4

> e.findAll("div:scope div")

1, 2, 3, 4

> e.findAll("div:scope #3")

3

> e.findAll("body > :scope > div")

1, 2, 3, 4

> e.findAll("div, :scope")

context, 1, 2, 3, 4

> e.findAll("body > :scope > div, :scope")

context, 1, 2, 3, 4

> e.findAll(":not(:scope)")

empty set
Received on Monday, 31 October 2011 20:56:28 GMT

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