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

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 UTC