envjs / env-js

A pure-JavaScript browser environment.
http://www.envjs.com/
87 stars 19 forks source link

NodeList.toArray() returns the incorrect type #12

Open orslumen opened 13 years ago

orslumen commented 13 years ago

When parsing a Document Fragment, the appendChild method calls Array.prototype.push.apply(nodelist, newChild.childNodes.toArray() );

But as NodeList.toArray() returns self, you will receive Exception TypeError: Function.prototype.apply: Arguments list has wrong type.

I got around this issue by putting back the original toArray() method: toArray: function () { var children = []; for ( var i=0; i < this.length; i++) { children.push (this[i]); } return children; },

See commit https://github.com/orslumen/env-js/commit/bb3c8db36cf904ccd3f7da62b10081156d143a77