const nodeIterator = document.createNodeIterator(
document.body,
NodeFilter.SHOW_ELEMENT,
{
acceptNode(node) {
return NodeFilter.FILTER_ACCEPT;
},
},
);
nodeIterator.detach(); // detaches the iterator
nodeIterator.nextNode(); // throws an INVALID_STATE_ERR exceptionNodeIterator: detach() method / notebook
NodeIterator: detach() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.