I'm trying to shim Element.prototype.children
which should return a HTMLCollection
There is a window.HTMLCollection
However
var h = new HTMLCollection();
//TypeErrror: HTMLCollection is not a constructor
and
var h = Object.create(HTMLCollection.prototype);
h[0] = div;
h.item(0);
// Could not convert JavaScript argument
Test Firefox 7 and Chrome
Apart from shimming HTMLCollection
is there any way to interact with it?
Also provide feedback on this github issue if you can suggest a solution
Here's how I would do it:
where
arr
is a regular array that contains all the DOM elements which should be inside the HTMLCollection.To do list:
arr
should be checked beforehand: Is it an array? Are all elements of that array DOM elements?