The goog.dom.TextRangeIterator Class

goog.dom.TextRangeIterator
> goog.dom.RangeIterator
> goog.dom.TagIterator
> goog.iter.Iterator

goog.dom.TextRangeIterator(startNode, startOffset, endNode, endOffset, opt_reverse)

Subclass of goog.dom.TagIterator that iterates over a DOM range. It adds functions to determine the portion of each text node that is selected.

startNode {Node}
The starting node position.
startOffset {number}
The offset in to startNode. If startNode is an element, indicates an offset in to childNodes. If startNode is a text node, indicates an offset in to nodeValue.
endNode {Node}
The ending node position.
endOffset {number}
The offset in to endNode. If endNode is an element, indicates an offset in to childNodes. If endNode is a text node, indicates an offset in to nodeValue.
opt_reverse {boolean=}
Whether to traverse nodes in reverse.

.__iterator__(opt_keys)

Inherited from goog.iter.Iterator .

Returns the {@code Iterator} object itself. This is used to implement the iterator protocol in JavaScript 1.7

opt_keys {boolean=}
Whether to return the keys or values. Default is to only return the values. This is being used by the for-in loop (true) and the for-each-in loop (false). Even though the param gives a hint about what the iterator will return there is no guarantee that it will return the keys when true is passed.
returns {!goog.iter.Iterator}
The object itself.

.clone()

returns {goog.dom.TextRangeIterator}
An identical iterator.

.constrained {boolean}

Inherited from goog.dom.TagIterator .

Whether the iterator is constrained to the starting node and its children.

.copyFrom()

.depth {number}

Inherited from goog.dom.TagIterator .

The tree depth of this position relative to where the iterator started. The depth is considered to be the tree depth just past the current node, so if an iterator is at position

    
|
(i.e. the node is the div and the type is START_TAG) its depth will be 1.

.equals(other)

Inherited from goog.dom.TagIterator .

Test if two iterators are at the same position - i.e. if the node and tagType is the same. This will still return true if the two iterators are moving in opposite directions or have different constraints.

other {goog.dom.TagIterator}
The iterator to compare to.
returns {boolean}
Whether the two iterators are at the same position.

.getEndNode()

returns {Node}
The iterator's end node.

.getEndTextOffset()

returns {number}
The end offset into the current node, or -1 if the current node is not a text node.

.getStartNode()

returns {Node}
node The iterator's start node.

.getStartTextOffset()

returns {number}
The offset into the current node, or -1 if the current node is not a text node.

.isEndTag()

Inherited from goog.dom.TagIterator .

returns {boolean}
Whether this iterator's position is an end tag position.

.isLast()

returns {boolean}
Whether a call to next will fail.

.isNonElement()

Inherited from goog.dom.TagIterator .

returns {boolean}
Whether this iterator's position is not at an element node.

.isStartTag()

Inherited from goog.dom.TagIterator .

returns {boolean}
Whether this iterator's position is a start tag position.

.next()

Move to the next position in the selection. Throws {@code goog.iter.StopIteration} when it passes the end of the range.

returns {Node}
The node at the next position.

.node {Node}

Inherited from goog.dom.TagIterator .

The node this position is located on.

.restartTag()

Inherited from goog.dom.TagIterator .

Restart the current tag.

.reversed {boolean}

Inherited from goog.dom.TagIterator .

Whether the node iterator is moving in reverse.

.setEndNode(node)

Change the end node of the iterator.

node {Node}
The new end node.

.setPosition(node, opt_tagType, opt_depth)

Inherited from goog.dom.TagIterator .

Set the position of the iterator. Overwrite the tree node and the position type which can be one of the {@link goog.dom.TagWalkType} token types. Only overwrites the tree depth when the parameter is specified.

node {Node}
The node to set the position to.
opt_tagType {goog.dom.TagWalkType?=}
The type of the position Defaults to the start of the given node.
opt_depth {number=}
The tree depth.

.setStartNode(node)

Change the start node of the iterator.

node {Node}
The new start node.

.skipTag()

.splice(var_args)

Inherited from goog.dom.TagIterator .

Replace the current node with the list of nodes. Reset the iterator so that it visits the first of the nodes next.

var_args {...Object}
A list of nodes to replace the current node with. If the first argument is array-like, it will be used, otherwise all the arguments are assumed to be nodes.

.tagType {goog.dom.TagWalkType}

Inherited from goog.dom.TagIterator .

The type of this position.