- From: Ryosuke Niwa <notifications@github.com>
- Date: Tue, 22 Jun 2021 17:20:26 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 23 June 2021 00:20:52 UTC
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