lachlan.hunt at lachy.id.au
Wed May 10 23:17:08 PDT 2006
Dean Edwards wrote:
> objects (especially with the introduction of Mozilla's Array Extras
> ). This makes iteration over DOM queries more flexible.
It sounds like a nice idea, but there are some problems with it that I
can see. NodeLists are live, meaning that changes made to the
underlying DOM will be reflected in the list. Conversely, it means that
any changes made to the NodeList would logically need to be reflected in
e.g. If you get a node list of P elements like this
var pNodes = document.getElementsByTagName("p");
then later in the script you remove one of those P elements from the
DOM, it will also be removed from that NodeList.
This is a problem for your idea because it means that changes made to
the NodeList would also need to be made to the DOM, in order to keep
them in sync.
e.g. What would happen if you used the Array push() function on the
Where in the DOM would that new node be added?
More information about the whatwg