Handy treewalker thingie:
const acceptNodeFilter = {
acceptNode: function(aNode) {
return NodeFilter.FILTER_ACCEPT;
},
toString: function() {
return "[object NodeFilter]";
}
};
const foo = {
getChildElements: function(aNode) {
var walker = aNode.ownerDocument.createTreeWalker(aNode, NodeFilter.SHOW_ELEMENT, acceptNodeFilter, true);
var rv = [];
var firstChildNode = walker.firstChild();
if (firstChildNode) {
rv.push(firstChildNode);
while (walker.nextSibling()) {
rv.push(walker.currentNode);
}
}
return rv;
}
}
From:
http://weblogs.mozillazine.org/mt/mt-comments.cgi?entry_id=5869
0 Comments:
Post a Comment
<< Home