RE: [DOM4] Short and Efficent DOM Traversal
Domenic Denicola <[email protected]>
| Newsgroups | gmane.comp.web.dom.general,gmane.org.w3c.webapps |
|---|---|
| Message-ID | <B4AE8F4E86E26C47AC407D49872F6F9F8786C2CC@BY2PRD0510MB354.namprd05.prod.outlook.com> |
Both of these seem very like the ES6 iterator interface. Can you just use that instead of minting a new iterable/iterator interface, viz. `.iterator()`/`.next()` or `.nextNode()`? The resulting code would be
```js
var tw = document.createTreeWalker(document.body, "ul.menu > li");
for (var node of tw) {
if (...) break;
...
}
```
for François's proposal, whereas it would be
```js
var iterable = document.querySelectorAll("div");
for (var current of iterable) {
current.remove();
}
```
for Ojan's.