I'm implementing all of the optional E4X features described in ECMA-357 Annex A and I'm having trouble implementing domNodeList (§A.1.2 and §A.2.2). How would I create my own NodeList object?
Even if I create a new XMLDocument and append every domNode() representation of the nodes in an XMLList, I still don't see how I could create a NodeList containing everything as ments and processing instructions are usually excluded.
I'm implementing all of the optional E4X features described in ECMA-357 Annex A and I'm having trouble implementing domNodeList (§A.1.2 and §A.2.2). How would I create my own NodeList object?
Even if I create a new XMLDocument and append every domNode() representation of the nodes in an XMLList, I still don't see how I could create a NodeList containing everything as ments and processing instructions are usually excluded.
Share Improve this question edited Nov 21, 2009 at 22:57 munity wiki3 revs
Eli Grey 3
- What is the context of this question? What are you writing? – Ryan Lynch Commented Nov 21, 2009 at 21:15
- 2 Ryan, do you not see domNodeList? I also clearly state where it's defined in ECMA-357. – Eli Grey Commented Nov 21, 2009 at 21:35
- Crescent: So the best solution can be put in the post by any menter. – Eli Grey Commented Nov 21, 2009 at 22:14
1 Answer
Reset to default 15I figured out that I could use the childNodes attribute of a document fragment to create a NodeList. This was my solution:
XML.prototype.function::domNodeList = function () {
var fragment = document.createDocumentFragment(),
len = this.length(),
i = 0;
for (; i < len; i++) {
fragment.appendChild(this[i].domNode());
}
return fragment.childNodes;
}