I'd like to see this thing smell like a normal Array, plus useful node
methods:
1. It should have at least all of the non-mutating Array methods on
> it. Possibly the mutating methods too if we allow the returned object
> to be mutable.
>
Agreed.
> 2. It should have a object on the prototype chain where we can insert
> functions that are specifically useful for lists of nodes. Examples
> include .find/.findAll/.matchesSelector/.remove/.addEventListener
>
It would be nice if it also had getElementsBy*. This object (ElementList?)
could be a beachhead allowing us to add more useful functionality to lists
of elements in the browser over time.
Since this is a totally new API, we're also not bound by the API for
individual nodes, so we could use shorter names, like .is() for
matchesSelector() and .on() for addEventListener.
> 3. It would be good if it had the Array prototype object on it's
> prototype chain so that if Array.prototype was extended, it would
> affect this object too.
>
Absolutely.
> 4. The object will *not* be live since live results from selector
> matching is slow.
Agreed.
Yehuda Katz
(ph) 718.877.1325
On Fri, Nov 11, 2011 at 6:04 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> On Fri, Nov 11, 2011 at 5:59 PM, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
> > On Fri, Nov 11, 2011 at 5:52 PM, Rick Waldron <waldron.rick@gmail.com>
> wrote:
> >> Right, but I'm saying: why create yet more "stuff" in the DOM?
> >>
> >> findAll will return a "NodeArray" while querySelectorAll and friends
> return static and live NodeLists? No thanks.
> >
> > I'm not sure what you would prefer. Make findAll return an Array? (We
> > miss out on a *lot* of cool and useful stuff we could do.) Make
> > findAll return immutable live NodeLists? (Ditto, but for different
> > reasons.) Change qSA to return a NodeArray or Array? (Would be nice,
> > but probably not doable for compat reasons.)
>
> Actually, if we add .item to NodeArray then it's entirely possible
> that we can make qSA return a NodeArray. I'm not entirely convinced
> that's worth it though.
>
> / Jonas
>
>