The goog.dom.AbstractMultiRange Class

goog.dom.AbstractMultiRange
> goog.dom.AbstractRange

goog.dom.AbstractMultiRange()

Creates a new multi range with no properties. Do not use this constructor: use one of the goog.dom.Range.createFrom* methods instead.

.__iterator__(opt_keys)

Inherited from goog.dom.AbstractRange .

Returns a RangeIterator over the contents of the range. Regardless of the direction of the range, the iterator will move in document order.

opt_keys {boolean=}
Unused for this iterator.
returns {goog.dom.RangeIterator}
An iterator over tags in the range.

.clone()

Inherited from goog.dom.AbstractRange .

returns {goog.dom.AbstractRange}
A clone of this range.

.collapse(toAnchor)

Inherited from goog.dom.AbstractRange .

Collapses the range to one of its boundary points.

toAnchor {boolean}
Whether to collapse to the anchor of the range.

.containsNode(node, opt_allowPartial)

Inherited from goog.dom.AbstractRange .

Tests if this range contains the given node.

node {Node}
The node to test for.
opt_allowPartial {boolean=}
If not set or false, the node must be entirely contained in the selection for this function to return true.
returns {boolean}
Whether this range contains the given node.

.containsRange(range, opt_allowPartial)

Tests if this range contains the given range.

range {goog.dom.AbstractRange}
The range to test.
opt_allowPartial {boolean=}
If true, the range can be partially contained in the selection, otherwise the range must be entirely contained.
returns {boolean}
Whether this range contains the given range.

.getAnchorNode()

Inherited from goog.dom.AbstractRange .

returns {Node}
The element or text node the range is anchored at.

.getAnchorOffset()

Inherited from goog.dom.AbstractRange .

returns {number}
The offset into the node the range is anchored at. For text nodes, this is an offset into the node value. For elements, this is an offset into the childNodes array.

.getBrowserRangeObject()

Inherited from goog.dom.AbstractRange .

returns {Range|TextRange}
The native browser range object.

.getContainer()

Inherited from goog.dom.AbstractRange .

returns {Node}
The deepest node that contains the entire range.

.getContainerElement()

Inherited from goog.dom.AbstractRange .

Returns the deepest element in the tree that contains the entire range.

returns {Element}
The deepest element that contains the entire range.

.getDocument()

Inherited from goog.dom.AbstractRange .

returns {Document}
The document this selection is a part of.

.getEndNode()

Inherited from goog.dom.AbstractRange .

returns {Node}
The element or text node the range ends in.

.getEndOffset()

Inherited from goog.dom.AbstractRange .

returns {number}
The offset into the node the range ends in. For text nodes, this is an offset into the node value. For elements, this is an offset into the childNodes array.

.getFocusNode()

Inherited from goog.dom.AbstractRange .

returns {Node}
The element or text node the range is focused at - i.e. where the cursor is.

.getFocusOffset()

Inherited from goog.dom.AbstractRange .

returns {number}
The offset into the node the range is focused at - i.e. where the cursor is. For text nodes, this is an offset into the node value. For elements, this is an offset into the childNodes array.

.getHtmlFragment()

Inherited from goog.dom.AbstractRange .

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.

returns {string}
HTML fragment of the range, does not include context containing elements.

.getPastableHtml()

Inherited from goog.dom.AbstractRange .

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.

returns {string}
Pastable HTML of the range, including context containing elements.

.getStartNode()

Inherited from goog.dom.AbstractRange .

returns {Node}
The element or text node the range starts in. For text ranges, the range comprises all text between the start and end position. For other types of range, start and end give bounds of the range but do not imply all nodes in those bounds are selected.

.getStartOffset()

Inherited from goog.dom.AbstractRange .

returns {number}
The offset into the node the range starts in. For text nodes, this is an offset into the node value. For elements, this is an offset into the childNodes array.

.getText()

Inherited from goog.dom.AbstractRange .

returns {string}
The text content of the range.

.getTextRange(i)

Inherited from goog.dom.AbstractRange .

Get the i-th text range in this range. The behavior is undefined if i >= getTextRangeCount or i < 0.

i {number}
The range number to retrieve.
returns {goog.dom.TextRange}
The i-th text range.

.getTextRangeCount()

Inherited from goog.dom.AbstractRange .

returns {number}
The number of text ranges in this range.

.getTextRanges()

Inherited from goog.dom.AbstractRange .

Gets an array of all text ranges this range is comprised of. For non-multi ranges, returns a single element array containing this.

returns {Array.<goog.dom.TextRange>}
Array of text ranges.

.getType()

Inherited from goog.dom.AbstractRange .

returns {goog.dom.RangeType}
The type of range represented by this object.

.getValidHtml()

Inherited from goog.dom.AbstractRange .

Returns valid HTML for this range. This is fast on IE, and semi-fast on other browsers.

returns {string}
Valid HTML of the range, including context containing elements.

.getWindow()

Inherited from goog.dom.AbstractRange .

returns {Window}
The window this selection is a part of.

.insertNode(node, before)

Inserts a node before (or after) the range. The range may be disrupted beyond recovery because of the way this splits nodes.

node {Node}
The node to insert.
before {boolean}
True to insert before, false to insert after.
returns {Node}
The node added to the document. This may be different than the node parameter because on IE we have to clone it.

.isCollapsed()

Inherited from goog.dom.AbstractRange .

returns {boolean}
Whether the range is collapsed.

.isRangeInDocument()

Inherited from goog.dom.AbstractRange .

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.

returns {boolean}
Whether the range is valid.

.isReversed()

Inherited from goog.dom.AbstractRange .

returns {boolean}
Whether the selection is reversed.

.removeContents()

Inherited from goog.dom.AbstractRange .

Removes the contents of the range from the document.

.replaceContentsWithNode(node)

Inherited from goog.dom.AbstractRange .

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.

node {Node}
The node to insert.
returns {Node}
The node added to the document. This may be different than the node parameter because on IE we have to clone it.

.saveUsingCarets()

Inherited from goog.dom.AbstractRange .

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.

returns {goog.dom.SavedCaretRange?}
A range representation that can be restored as long as carets are not removed. Returns null if carets could not be created.

.saveUsingDom()

Inherited from goog.dom.AbstractRange .

Saves the range so that if the start and end nodes are left alone, it can be restored.

returns {goog.dom.SavedRange}
A range representation that can be restored as long as the endpoint nodes of the selection are not modified.

.select()

Inherited from goog.dom.AbstractRange .

Sets this range as the selection in its window.

.setBrowserRangeObject(nativeRange)

Inherited from goog.dom.AbstractRange .

Sets the native browser range object, overwriting any state this range was storing.

nativeRange {Range|TextRange}
The native browser range object.
returns {boolean}
Whether the given range was accepted. If not, the caller will need to call goog.dom.Range.createFromBrowserRange to create a new range object.

.surroundWithNodes(startNode, endNode)

Surrounds this range with the two given nodes. The range may be disrupted beyond recovery because of the way this splits nodes.

startNode {Element}
The node to insert at the start.
endNode {Element}
The node to insert at the end.