Home

# Class goog.dom.TagIterator

A DOM tree traversal iterator. Starting with the given node, the iterator walks the DOM in order, reporting events for the start and end of Elements, and the presence of text nodes. For example:

    <div>1<span>2</span>3</div>

Will return the following nodes: `[div, 1, span, 2, span, 3, div]` With the following states: `[START, OTHER, START, OTHER, END, OTHER, END]` And the following depths `[1, 1, 2, 2, 1, 1, 0]` Imagining `|` represents iterator position, the traversal stops at each of the following locations:

    <div>|1|<span>|2|</span>|3|</div>|

The iterator can also be used in reverse mode, which will return the nodes and states in the opposite order. The depths will be slightly different since, like in normal mode, the depth is computed *after* the given node. Lastly, it is possible to create an iterator that is unconstrained, meaning that it will continue iterating until the end of the document instead of until exiting the start node.extends goog.iter.Iterator

Instance Method Summary
| `clone() ⇒ ?goog.dom.TagIterator`
| `copyFrom(?goog.dom.TagIterator other)` Replace this iterator's values with values from another.
| `equals(?goog.dom.TagIterator other) ⇒ boolean` 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.
| `isEndTag() ⇒ boolean`
| `isNonElement() ⇒ boolean`
| `isStartTag() ⇒ boolean`
| `isStarted() ⇒ boolean`
| `next() ⇒ ?Node` Move to the next position in the DOM tree.
| `restartTag()` Restart the current tag.
| `setPosition(?Node node, ?goog.dom.TagWalkType= opt_tagType, number= opt_depth)` 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.
| `skipTag()` Skip the current tag.
| `splice((Object|null|undefined) var_args)` Replace the current node with the list of nodes. Reset the iterator so that it visits the first of the nodes next.