Creating a DOM NodeList

前端 未结 1 443
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 16:58

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

相关标签:
1条回答
  • 2020-12-16 17:21

    I 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;
    }
    
    0 讨论(0)
提交回复
热议问题