Re: [whatwg/dom] Suggestion: new method - getNodesByType (#992)

There is also [`NodeIterator`](https://developer.mozilla.org/en-US/docs/Web/API/NodeIterator).
```
function* getNodesByType(root, nodeType) {
    const nodeIterator = document.createNodeIterator(root, NodeFilter.SHOW_ALL, (node) => node.nodeType == nodeType);
    if (nodeIterator.referenceNode && nodeIterator.referenceNode.nodeType == nodeType)
        yield nodeIterator.referenceNode;
    while (nodeIterator.nextNode())
        yield nodeIterator.referenceNode;
}
```

I don't think we want to invent yet another way of iterating over nodes of a particular criteria at this point unless it provides a significant improvement / value over existing methods.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/992#issuecomment-866423343

Received on Wednesday, 23 June 2021 00:20:52 UTC