- From: Erik Arvidsson <arv@chromium.org>
- Date: Mon, 26 Apr 2010 09:49:52 -0700
On Sun, Apr 25, 2010 at 01:07, David Bruant <bruant at enseirb-matmeca.fr> wrote: > Le 25/04/2010 00:39, J Z a ?crit?: >> >> I have thought a lot about weirdnesses that people could think about like >> trying to assign a value to the HTMLCollection (divs[14] = myOtherDiv), but >> once again, it wouldn't be more allowed than it currently is (I have no idea >> of what happens today, but if an error is thrown in a for-loop, it should >> throw an error as well in a call within a forEach). > > How would destructive methods like `push` or `sort` behave? Would > `document.body.childNodes.push(document.createTextNode('foo'))` append text > node to a body element? Or would it be a noop? > > That is actually a very good point. > It think that the behavior should be exactly the same as "an equivalent > without array methods". (this point of my proposal would need to be made > completly explicit for each method) One way to solve this could be to split Array into two interfaces. One to be used with immutable array like objects and one to use to mutate objects. Then we could apply the immutable array like interface to NodeList and its related interfaces. The benefit of doing that is that NodeList.prototype.push would be undefined instead of failing when called. -- erik
Received on Monday, 26 April 2010 09:49:52 UTC