goog.dom.AbstractRange
Classgoog.dom.AbstractRange()
Creates a new selection with no properties. Do not use this constructor - use one of the goog.dom.Range.from* methods instead.
.__iterator__(opt_keys)
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
=}
goog.dom.RangeIterator
}
.clone()
goog.dom.AbstractRange
}
.collapse(toAnchor)
Collapses the range to one of its boundary points.
toAnchor
{boolean
}
.containsNode(node, opt_allowPartial)
Tests if this range contains the given node.
node
{Node
}
opt_allowPartial
{boolean
=}
boolean
}
.containsRange(range, opt_allowPartial)
Tests if this range contains the given range.
range
{goog.dom.AbstractRange
}
opt_allowPartial
{boolean
=}
boolean
}
.getAnchorNode()
Node
}
.getAnchorOffset()
number
}
.getBrowserRangeObject()
Range
|TextRange
}
.getBrowserSelectionForWindow(win)
Gets the browser native selection object from the given window.
win
{Window
}
Object
}
.getContainer()
Node
}
.getContainerElement()
Returns the deepest element in the tree that contains the entire range.
Element
}
.getDocument()
Document
}
.getEndNode()
Node
}
.getEndOffset()
number
}
.getFocusNode()
Node
}
.getFocusOffset()
number
}
.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.
string
}
.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.
string
}
.getStartNode()
Node
}
.getStartOffset()
number
}
.getText()
string
}
.getTextRange(i)
Get the i-th text range in this range. The behavior is undefined if i >= getTextRangeCount or i < 0.
i
{number
}
goog.dom.TextRange
}
.getTextRangeCount()
number
}
.getTextRanges()
Gets an array of all text ranges this range is comprised of. For non-multi ranges, returns a single element array containing this.
Array
.<goog.dom.TextRange
>}
.getType()
goog.dom.RangeType
}
.getValidHtml()
Returns valid HTML for this range. This is fast on IE, and semi-fast on other browsers.
string
}
.getWindow()
Window
}
.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
}
before
{boolean
}
Node
}
.isCollapsed()
boolean
}
.isNativeControlRange(range)
Tests if the given Object is a controlRange.
range
{Object
}
boolean
}
.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.
boolean
}
.isReversed()
boolean
}
.removeContents()
Removes the contents of the range from the document.
.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.
node
{Node
}
Node
}
.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.
goog.dom.SavedCaretRange
?}
.saveUsingDom()
Saves the range so that if the start and end nodes are left alone, it can be restored.
goog.dom.SavedRange
}
.select()
Sets this range as the selection in its window.
.setBrowserRangeObject(nativeRange)
Sets the native browser range object, overwriting any state this range was storing.
nativeRange
{Range
|TextRange
}
boolean
}
.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
}
endNode
{Element
}