---
title: "NodeIterator | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Interface NodeIterator

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator)

interface NodeIterator {  
    [filter](#filter): [NodeFilter](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.NodeFilter/) | null;  
    [pointerBeforeReferenceNode](#pointerbeforereferencenode): boolean;  
    [referenceNode](#referencenode): [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/);  
    [root](#root): [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/);  
    [whatToShow](#whattoshow): number;  
    [detach](#detach-1)(): void;  
    [nextNode](#nextnode-1)(): [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/) | null;  
    [previousNode](#previousnode-1)(): [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/) | null;  
}

##### Index

### Properties[](#properties)

[filter](#filter) [pointerBeforeReferenceNode](#pointerbeforereferencenode) [referenceNode](#referencenode) [root](#root) [whatToShow](#whattoshow)

### Methods[](#methods)

[detach](#detach) [nextNode](#nextnode) [previousNode](#previousnode)

## Properties[](#properties-1)

### `Readonly`filter[](#filter)

filter: [NodeFilter](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.NodeFilter/) | null

The **`NodeIterator.filter`** read-only property returns a NodeFilter object, that is an object which implements an acceptNode(node) method, used to screen nodes.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator/filter)

### `Readonly`pointerBeforeReferenceNode[](#pointerbeforereferencenode)

pointerBeforeReferenceNode: boolean

The **`NodeIterator.pointerBeforeReferenceNode`** read-only property returns a boolean flag that indicates whether the NodeFilter is anchored before (if this value is true) or after (if this value is false) the anchor node indicated by the NodeIterator.referenceNode property.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator/pointerBeforeReferenceNode)

### `Readonly`referenceNode[](#referencenode)

referenceNode: [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/)

The **`NodeIterator.referenceNode`** read-only property returns the Node to which the iterator is anchored; as new nodes are inserted, the iterator remains anchored to the reference node as specified by this property.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator/referenceNode)

### `Readonly`root[](#root)

root: [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/)

The **`NodeIterator.root`** read-only property represents the Node that is the root of what the NodeIterator traverses.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator/root)

### `Readonly`whatToShow[](#whattoshow)

whatToShow: number

The **`NodeIterator.whatToShow`** read-only property represents an unsigned integer representing a bitmask signifying what types of nodes should be returned by the NodeIterator.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator/whatToShow)

## Methods[](#methods-1)

### detach[](#detach)

-   detach(): void[](#detach-1)
    
    The **`NodeIterator.detach()`** method is a no-op, kept for backward compatibility only.
    
    #### Returns void
    
    #### Deprecated[](#deprecated)
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator/detach)
    

### nextNode[](#nextnode)

-   nextNode(): [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/) | null[](#nextnode-1)
    
    The **`NodeIterator.nextNode()`** method returns the next node in the set represented by the NodeIterator and advances the position of the iterator within the set. The first call to nextNode() returns the first node in the set.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator/nextNode)
    
    #### Returns [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/) | null
    

### previousNode[](#previousnode)

-   previousNode(): [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/) | null[](#previousnode-1)
    
    The **`NodeIterator.previousNode()`** method returns the previous node in the set represented by the NodeIterator and moves the position of the iterator backwards within the set.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeIterator/previousNode)
    
    #### Returns [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/) | null
