Home

# Class goog.dom.browserrange.AbstractRange

The constructor for abstract ranges. Don't call this from subclasses.

Instance Method Summary
| `__iterator__(boolean= opt_keys) ⇒ ?goog.dom.RangeIterator` Returns a RangeIterator over the contents of the range. Regardless of the direction of the range, the iterator will move in document order.
| `clone() ⇒ ?goog.dom.browserrange.AbstractRange`
| `collapse(boolean toStart)` Collapses the range to one of its boundary points.
| `compareBrowserRangeEndpoints((Range|TextRange|null) range, ?goog.dom.RangeEndpoint thisEndpoint, ?goog.dom.RangeEndpoint otherEndpoint) ⇒ number` Compares one endpoint of this range with the endpoint of another browser native range object.
| `containsNode(?Node node, boolean= opt_allowPartial) ⇒ boolean` Tests if this range contains the given node.
| `containsRange(?goog.dom.browserrange.AbstractRange abstractRange, boolean= opt_allowPartial) ⇒ boolean` Tests if this range contains the given range.
| `getBrowserRange() ⇒ (Range|TextRange|null)` Returns the browser native implementation of the range. Please refrain from using this function - if you find you need the range please add wrappers for the functionality you need rather than just using the native range.
| `getContainer() ⇒ ?Node` Returns the deepest node in the tree that contains the entire range.
| `getEndNode() ⇒ ?Node` Returns the node the range ends in.
| `getEndOffset() ⇒ number` Returns the offset into the node the range ends in.
| `getHtmlFragment() ⇒ string` Returns the HTML fragment this range selects. This is slow on all browsers.
| `getStartNode() ⇒ ?Node` Returns the node the range starts in.
| `getStartOffset() ⇒ number` Returns the offset into the node the range starts in.
| `getText() ⇒ string`
| `getValidHtml() ⇒ string` Returns valid HTML for this range. This is fast on IE, and semi-fast on other browsers.
| `insertNode(?Node node, boolean before) ⇒ ?Node` Inserts a node before (or after) the range. The range may be disrupted beyond recovery because of the way this splits nodes.
| `isCollapsed() ⇒ boolean` Tests if the selection is collapsed - i.e. is just a caret.
| `removeContents()` Removes the contents of the range from the document. As a side effect, the selection will be collapsed. The behavior of content removal is normalized across browsers. For instance, IE sometimes creates extra text nodes that a W3C browser does not. That behavior is corrected for.
| `select(boolean= opt_reverse)` Set this range as the selection in its window.
| `surroundContents(?Element element) ⇒ ?Element` Surrounds the text range with the specified element (on Mozilla) or with a clone of the specified element (on IE). Returns a reference to the surrounding element if the operation was successful; returns null if the operation failed.
| `surroundWithNodes(?Element startNode, ?Element endNode)` Surrounds this range with the two given nodes. The range may be disrupted beyond recovery because of the way this splits nodes.