Firefox Tomorrow

web api interface

NodeIterator

View on MDN ↗

The NodeIterator interface represents an iterator to traverse nodes of a DOM subtree in document order.

A NodeIterator can be created using the createNodeIterator() method, as follows:

const nodeIterator = document.createNodeIterator(root, whatToShow, filter);

Instance properties

This interface doesn’t inherit any property.

  • root Read only
    • : Returns a Node representing the root node, as specified when the NodeIterator was created.
  • whatToShow Read only
    • : Returns an unsigned long bitmask that describes the types of Node to be matched. Non-matching nodes are skipped, but relevant child nodes may be included.
  • filter Read only
    • : Returns a NodeFilter used to select the relevant nodes.
  • referenceNode Read only
    • : Returns the Node to which the iterator is anchored.
  • pointerBeforeReferenceNode Read only
    • : Returns a boolean indicating whether or not the NodeIterator is anchored before the referenceNode. If false, it indicates that the iterator is anchored after the reference node.

Instance methods

This interface doesn’t inherit any method.

  • detach() Deprecated
    • : This is a legacy method, and no longer has any effect. Previously it served to mark a NodeIterator as disposed, so it could be reclaimed by garbage collection.
  • previousNode()
    • : Returns the previous Node in the document, or null if there are none.
  • nextNode()
    • : Returns the next Node in the document, or null if there are none.

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also