NodeIterator: detach() method
Deprecated
Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.>
The NodeIterator.detach() method is a no-op, kept for
backward compatibility only.
Originally, it detached the NodeIterator from the set over which it
iterates, releasing any resources used by the set and setting the iterator's state to
INVALID. Once this method had been called, calls to other methods on
NodeIterator would raise the INVALID_STATE_ERR exception.
Syntax
js
detach()
Parameters
None.
Return value
None (undefined).
Examples
js
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 exception
Specifications
| Specification |
|---|
| DOM> # dom-nodeiterator-detach> |
Browser compatibility
See also
- The interface it belongs to:
NodeIterator.