W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2010

NodeList.toArray()

From: Jeff Schiller <codedread@gmail.com>
Date: Tue, 24 Aug 2010 16:37:27 -0700
Message-ID: <AANLkTimRj9DiWHLqz=qXTfxJ0R=VfAQBHZHm0+UrCwjM@mail.gmail.com>
To: www-dom@w3.org
This has probably been suggested before, but here goes.

Sometimes you need a live NodeList (even though they can be poor performers)
and sometimes you simply want an array-like object that isn't "live".

1) I propose adding a simple method to the NodeList interface:


interface NodeList <core.html#ID-536297177> {
  Node <core.html#ID-1950641247>               item
<core.html#ID-844377136>(in unsigned long index);
  readonly attribute unsigned long   length <core.html#ID-203510337>;

*  Node[]             toArray();*
};


toArray() returns a static array of Node elements.

2) I notice that I never see arrays represented in DOM IDLs.  It might be
that I missed it, but I suspect it's because I don't understand something
about the IDLs - maybe they are trying to be language-neutral?  Can this get
fixed?  What software language doesn't have an array-like construct?  If
there's ultimately no nice way to represent an array in IDL syntax (?) then
I would suggest defining a dummy array-like collection that is not live - is
there such a beast?

Jeff
Received on Tuesday, 24 August 2010 23:38:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:05 GMT