NodeIterator: detach() method

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

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

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
detach
Deprecated
Chrome – Full support
Chrome 1 (Release date: 2008-12-11)
footnote
footnote Since Chrome 45, this method does nothing, as specified. See bug 40362826.
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 3.5 (Release date: 2009-06-30)
footnote
footnote Since Firefox 22, this method does nothing, as specified. See bug 823549.
Opera – Full support
Opera 9 (Release date: 2006-06-20)
footnote
footnote Since Opera 32, this method does nothing, as specified. See bug 40362826.
Safari – Full support
Safari 3 (Release date: 2007-10-26)
footnote
footnote Since Safari 10, this method does nothing, as specified. See bug 148454.
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote
footnote Since Chrome Android 45, this method does nothing, as specified. See bug 40362826.
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote
footnote Since Firefox for Android 22, this method does nothing, as specified. See bug 823549.
Opera Android – Full support
Opera Android 10.1 (Release date: 2010-11-09)
footnote
footnote Since Opera Android 32, this method does nothing, as specified. See bug 40362826.
Safari on iOS – Full support
Safari on iOS 3 (Release date: 2009-06-17)
footnote
footnote Since Safari on iOS 10, this method does nothing, as specified. See bug 148454.
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote
footnote Since Samsung Internet 5.0, this method does nothing, as specified. See bug 40362826.
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote
footnote Since WebView Android 45, this method does nothing, as specified. See bug 40362826.
WebView on iOS – Full support
WebView on iOS 3 (Release date: 2009-06-17)
footnote
footnote Since WebView on iOS 10, this method does nothing, as specified. See bug 148454.

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Deprecated. Not for use in new websites.
See implementation notes.

See also