Table of Contents

Class NodeIterator

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

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

[Value("NodeIterator")]
public class NodeIterator
Inheritance
NodeIterator
Inherited Members

Remarks

A NodeIterator can be created using the CreateNodeIterator(Node, ulong, NodeFilter?) method, as follows:

-The creator method: CreateNodeIterator(Node, ulong, NodeFilter?).
-Related interface: TreeWalker

See also on MDN

Constructors

NodeIterator()

public NodeIterator()

Properties

Filter

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

[Value("filter")]
public NodeFilter? Filter { get; }

Property Value

NodeFilter

A NodeFilter object.

Remarks

When creating the NodeIterator, the filter object is passed in as the
third parameter, and the object method acceptNode(node) is
called on every single node to determine whether or not to accept it. This function
should return the constant NodeFilter.FILTER_ACCEPT for cases when the
node should be accepted and NodeFilter.FILTER_REJECT for cases when the
node should be rejected.

-The interface this property belongs to: NodeIterator.

See also on MDN

PointerBeforeReferenceNode

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
ReferenceNode property.

[Value("pointerBeforeReferenceNode")]
public bool PointerBeforeReferenceNode { get; }

Property Value

bool

A boolean.

Remarks

-The interface it belongs to: NodeIterator

See also on MDN

ReferenceNode

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.

[Value("referenceNode")]
public Node ReferenceNode { get; }

Property Value

Node

A Node.

Remarks

-The interface it belongs to: NodeIterator

See also on MDN

Root

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

[Value("root")]
public Node Root { get; }

Property Value

Node

A Node.

Remarks

-The interface it belongs to: NodeIterator.

See also on MDN

WhatToShow

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

[Value("whatToShow")]
public ulong WhatToShow { get; }

Property Value

ulong

An unsigned integer.The values that can be combined to form the bitmask are:

Remarks

-The interface this property belongs to: NodeIterator.

See also on MDN

Methods

Detach()

IMPORTANT
Deprecated
The NodeIterator.detach() method is a no-op, kept for
backward compatibility only.
[Value("detach")]
public GlobalObject.Undefined Detach()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

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.

-The interface it belongs to: NodeIterator.

See also on MDN

NextNode()

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.

[Value("nextNode")]
public Node? NextNode()

Returns

Node

A Node representing the node after the current node in the set represented by this NodeIterator, or null if the current node is the last node in the set.

Remarks

This method returns null when there are no nodes left in the set.

In old browsers, as specified in old versions of the specifications, the method may
throws the INVALID_STATE_ERR DOMException if this method
is called after the Detach() method. Recent browsers never
throw.

-The interface it belongs to: NodeIterator.

See also on MDN

PreviousNode()

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.

[Value("previousNode")]
public Node? PreviousNode()

Returns

Node

A Node representing the node before the current node in the set represented by this NodeIterator, or null if the current node is the first node in the set.

Remarks

This method returns null when the current node is the first node in the
set.

In old browsers, as specified in old versions of the specifications, the method may
throws the INVALID_STATE_ERR DOMException if this method
is called after the Detach() method. Recent browsers never
throw.

-The interface it belongs to: NodeIterator.

See also on MDN