Home

# Class goog.dom.AbstractRange

Creates a new selection with no properties. Do not use this constructor - use one of the goog.dom.Range.from* methods instead.

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.AbstractRange`
| `collapse(boolean toAnchor)` Collapses the range to one of its boundary points.
| `containsNode(?Node node, boolean= opt_allowPartial) ⇒ boolean` Tests if this range contains the given node.
| `containsRange(?goog.dom.AbstractRange range, boolean= opt_allowPartial) ⇒ boolean` Tests if this range contains the given range.
| `getAnchorNode() ⇒ ?Node`
| `getAnchorOffset() ⇒ number`
| `getBrowserRangeObject() ⇒ (Range|TextRange|null)`
| `getContainer() ⇒ ?Node`
| `getContainerElement() ⇒ ?Element` Returns the deepest element in the tree that contains the entire range.
| `getDocument() ⇒ ?Document`
| `getEndNode() ⇒ ?Node`
| `getEndOffset() ⇒ number`
| `getFocusNode() ⇒ ?Node`
| `getFocusOffset() ⇒ number`
| `getHtmlFragment() ⇒ string` Returns the HTML fragment this range selects. This is slow on all browsers. The HTML fragment may not be valid HTML, for instance if the user selects from a to b inclusively in the following html: >div<a>/div<b This method will return a</div>b If you need valid HTML, use {@link #getValidHtml} instead.
| `getPastableHtml() ⇒ string` Returns pastable HTML for this range. This guarantees that any child items that must have specific ancestors will have them, for instance all TDs will be contained in a TR in a TBODY in a TABLE and all LIs will be contained in a UL or OL as appropriate. This is semi-fast on all browsers.
| `getStartNode() ⇒ ?Node`
| `getStartOffset() ⇒ number`
| `getText() ⇒ string`
| `getTextRange(number i) ⇒ ?goog.dom.TextRange` Get the i-th text range in this range. The behavior is undefined if i >= getTextRangeCount or i < 0.
| `getTextRangeCount() ⇒ number`
| `getTextRanges() ⇒ ?Array` Gets an array of all text ranges this range is comprised of. For non-multi ranges, returns a single element array containing this.
| `getType() ⇒ ?goog.dom.RangeType`
| `getValidHtml() ⇒ string` Returns valid HTML for this range. This is fast on IE, and semi-fast on other browsers.
| `getWindow() ⇒ ?Window`
| `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`
| `isRangeInDocument() ⇒ boolean` Tests whether this range is valid (i.e. whether its endpoints are still in the document). A range becomes invalid when, after this object was created, either one or both of its endpoints are removed from the document. Use of an invalid range can lead to runtime errors, particularly in IE.
| `isReversed() ⇒ boolean`
| `removeContents()` Removes the contents of the range from the document.
| `replaceContentsWithNode(?Node node) ⇒ ?Node` Replaces the range contents with (possibly a copy of) the given node. The range may be disrupted beyond recovery because of the way this splits nodes.
| `saveUsingCarets() ⇒ ?goog.dom.SavedCaretRange` Saves the range using HTML carets. As long as the carets remained in the HTML, the range can be restored...even when the HTML is copied across documents.
| `saveUsingDom() ⇒ ?goog.dom.SavedRange` Saves the range so that if the start and end nodes are left alone, it can be restored.
| `select()` Sets this range as the selection in its window.
| `setBrowserRangeObject((Range|TextRange|null) nativeRange) ⇒ boolean` Sets the native browser range object, overwriting any state this range was storing.
| `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.

Static Method Summary
| `getBrowserSelectionForWindow(?Window win) ⇒ ?Object` Gets the browser native selection object from the given window.
| `isNativeControlRange(?Object range) ⇒ boolean` Tests if the given Object is a controlRange.