I agree with this, but it might be too late to make this change.

The problem is that if we returned an Array object, it would not have
a .item function, which the currently returned NodeList has.

I guess we could return a Array object and add a .item function to it.

/ Jonas

On Sun, Aug 21, 2011 at 10:52 AM, Julien Richard-Foy
<jul...@richard-foy.fr> wrote:
> Since Javascript 1.6, a lot of useful collection functions are defined for
> Array [1]. Unfortunately, they can’t be used directly with results returned by
> .querySelectorAll, or even .getElementsByTagName since these functions return
> NodeLists.
> I understand the DOM API is defined without a language in mind, but these
> collection functions are really useful, easy to implement and already
> available in most mainstream languages. Therefore, why not create a base
> Traversable type which would be implemented by all collection types (like
> NodeList) and which would provide the so useful bunch of iteration methods?
> Are there some issues or drawbacks I did not think of?
>
> Regards,
> Julien
>
> [1]
> https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array#Iteration_methods
>
>
>

Reply via email to