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

Inheritance

Object
     goog.dom.AbstractRange

Constructor

goog.dom.AbstractRange()

Instance Methods

Public Protected Private
__iterator__()
Returns a RangeIterator over the contents of the range. Regardless of the direction of the range, the iterator will move in document order.
Returns:   An iterator over tags in the range.
code »
No description.
Returns:   A clone of this range.
code »
collapse()
Collapses the range to one of its boundary points.
code »
containsNode(nodeopt_allowPartial)
Tests if this range contains the given node.
Arguments:
node :
The node to test for.
opt_allowPartial :
If not set or false, the node must be entirely contained in the selection for this function to return true.
Returns:   Whether this range contains the given node.
code »
containsRange()
Tests if this range contains the given range.
Returns:   Whether this range contains the given range.
code »
getAnchorNode()
No description.
Returns:   The element or text node the range is anchored at.
code »
getAnchorOffset()
No description.
Returns:   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.
code »
getBrowserRangeObject()
Range | TextRange
No description.
Returns: 
Range | TextRange
  The native browser range object.
code »
getContainer()
No description.
Returns:   The deepest node that contains the entire range.
code »
getContainerElement()
Returns the deepest element in the tree that contains the entire range.
Returns:   The deepest element that contains the entire range.
code »
getDocument()
No description.
Returns:   The document this selection is a part of.
code »
getEndNode()
No description.
Returns:   The element or text node the range ends in.
code »
getEndOffset()
No description.
Returns:   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.
code »
getFocusNode()
No description.
Returns:   The element or text node the range is focused at - i.e. where the cursor is.
code »
getFocusOffset()
No description.
Returns:   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.
code »
getHtmlFragment()
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:   HTML fragment of the range, does not include context containing elements.
code »
getPastableHtml()
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:   Pastable HTML of the range, including context containing elements.
code »
getStartNode()
No description.
Returns:   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.
code »
getStartOffset()
No description.
Returns:   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.
code »
getText()
No description.
Returns:   The text content of the range.
code »
getTextRange()
Get the i-th text range in this range. The behavior is undefined if i >= getTextRangeCount or i < 0.
Returns:   The i-th text range.
code »
getTextRangeCount()
No description.
Returns:   The number of text ranges in this range.
code »
getTextRanges()
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 of text ranges.
code »
getType()
goog.dom.RangeType
No description.
Returns: 
goog.dom.RangeType
  The type of range represented by this object.
code »
getValidHtml()
Returns valid HTML for this range. This is fast on IE, and semi-fast on other browsers.
Returns:   Valid HTML of the range, including context containing elements.
code »
getWindow()
No description.
Returns:   The window this selection is a part of.
code »
insertNode()
Inserts a node before (or after) the range. The range may be disrupted beyond recovery because of the way this splits nodes.
Returns:   The node added to the document. This may be different than the node parameter because on IE we have to clone it.
code »
isCollapsed()
No description.
Returns:   Whether the range is collapsed.
code »
isRangeInDocument()
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:   Whether the range is valid.
code »
isReversed()
No description.
Returns:   Whether the selection is reversed.
code »
removeContents()
No description.
code »
replaceContentsWithNode(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.
Arguments:
node :
The node to insert.
Returns:   The node added to the document. This may be different than the node parameter because on IE we have to clone it.
code »
saveUsingCarets()
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:   A range representation that can be restored as long as carets are not removed. Returns null if carets could not be created.
code »
saveUsingDom()
Saves the range so that if the start and end nodes are left alone, it can be restored.
Returns:   A range representation that can be restored as long as the endpoint nodes of the selection are not modified.
code »
select()
No description.
code »
setBrowserRangeObject(nativeRange)
Sets the native browser range object, overwriting any state this range was storing.
Arguments:
nativeRange :
Range | TextRange
The native browser range object.
Returns:   Whether the given range was accepted. If not, the caller will need to call goog.dom.Range.createFromBrowserRange to create a new range object.
code »
surroundWithNodes()
Surrounds this range with the two given nodes. The range may be disrupted beyond recovery because of the way this splits nodes.
code »

Static Methods

goog.dom.AbstractRange.getBrowserSelectionForWindow(win)
Gets the browser native selection object from the given window.
Arguments:
win :
The window to get the selection object from.
Returns:   The browser native selection object, or null if it could not be retrieved.
code »
goog.dom.AbstractRange.isNativeControlRange(range)
Tests if the given Object is a controlRange.
Arguments:
range :
The range object to test.
Returns:   Whether the given Object is a controlRange.
code »

Package dom

Package Reference