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

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

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Tue, 15 Nov 2011 13:54:35 +0100
Message-ID: <4EC2610B.5060306@lachy.id.au>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: Alex Russell <slightlyoff@google.com>, Jonas Sicking <jonas@sicking.cc>, Webapps WG <public-webapps@w3.org>, Yehuda Katz <wycats@gmail.com>, John Resig <jeresig@gmail.com>, Paul Irish <paulirish@google.com>
On 2011-10-30 17:23, Tab Atkins Jr. wrote:
> If it's a NodeList (or something else that *subclasses* Array) we can
> do fun things like add .find to it, which returns the sorted union of
> calling .find on all the elements within it.  Returning a plain Array
> doesn't let us do that.

JS libraries more often work with Arrays and other numerically indexed 
objects internally anyway, containing elements from a wide variety of of 
sources, and so when I previously looked at adding such functionality, I 
determined that adding such a method to NodeList wouldn't make it 
available on other types of collections that are commonly used and thus 
limit its utility.

Right now, the spec does however handle that use case by doing this:

   document.querySelectorAll(":scope .foo", x);

Where x is either an individual element, or an Array, NodeList or 
numerically indexed object containing 0 or more Elements.

(It does however limit the result only to elements that are in the 
document, and any disconnected elements in the collection x would not be 
found.)

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/
Received on Tuesday, 15 November 2011 12:55:16 GMT

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