goog.dom.AbstractRange
Provided By | |
---|---|
All Known Direct Subclasses |
Creates a new selection with no properties. Do not use this constructor - use one of the goog.dom.Range.from* methods instead.
new AbstractRange()
Parameters | None. |
---|
Instance Methods
this.__iterator__( opt_keys ) → goog.dom.RangeIterator
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.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.clone() → goog.dom.AbstractRange
goog.dom.AbstractRange
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.collapse( toAnchor ) → void
void
Collapses the range to one of its boundary points.
Parameters |
|
---|
this.containsNode( node, opt_allowPartial ) → boolean
boolean
this.containsRange( range, opt_allowPartial ) → boolean
boolean
Tests if this range contains the given range.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.getAnchorNode() → (Node|null)
(Node|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getAnchorOffset() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getBrowserRangeObject() → (Range|TextRange|null)
(Range|TextRange|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getContainer() → (Node|null)
(Node|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getContainerElement() → (Element|null)
(Element|null)
Returns the deepest element in the tree that contains the entire range.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getDocument() → Document
Document
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getEndNode() → (Node|null)
(Node|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getEndOffset() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getEndPosition() → (goog.math.Coordinate|null)
(goog.math.Coordinate|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getFocusNode() → (Node|null)
(Node|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getFocusOffset() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getHtmlFragment() → string
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 #getValidHtml
instead.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getPastableHtml() → string
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.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getStartNode() → (Node|null)
(Node|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getStartOffset() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getStartPosition() → (goog.math.Coordinate|null)
(goog.math.Coordinate|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getText() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getTextRange( i ) → (goog.dom.AbstractRange|null)
(goog.dom.AbstractRange|null)
Get the i-th text range in this range. The behavior is undefined if i >= getTextRangeCount or i < 0.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getTextRangeCount() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getTextRanges() → Array<(goog.dom.AbstractRange|null)>
Array<(goog.dom.AbstractRange|null)>
Gets an array of all text ranges this range is comprised of. For non-multi ranges, returns a single element array containing this.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getType() → goog.dom.RangeType
goog.dom.RangeType
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getValidHtml() → string
string
Returns valid HTML for this range. This is fast on IE, and semi-fast on other browsers.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getWindow() → Window
Window
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.insertNode( node, before ) → (Node|null)
(Node|null)
Inserts a node before (or after) the range. The range may be disrupted beyond recovery because of the way this splits nodes.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.isCollapsed() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isRangeInDocument() → boolean
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.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isReversed() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.removeContents() → void
void
Removes the contents of the range from the document.
this.replaceContentsWithNode( node ) → (Node|null)
(Node|null)
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.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.saveUsingCarets() → (goog.dom.AbstractSavedCaretRange|null)
(goog.dom.AbstractSavedCaretRange|null)
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.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.saveUsingDom() → goog.dom.SavedRange
goog.dom.SavedRange
Saves the range so that if the start and end nodes are left alone, it can be restored.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.select() → void
void
Sets this range as the selection in its window.
this.setBrowserRangeObject( nativeRange ) → boolean
boolean
Sets the native browser range object, overwriting any state this range was storing.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.surroundWithNodes( startNode, endNode ) → void
void
Surrounds this range with the two given nodes. The range may be disrupted beyond recovery because of the way this splits nodes.
Parameters |
|
---|
Static Functions
AbstractRange.getBrowserSelectionForWindow( win ) → (Object|null)
(Object|null)
Gets the browser native selection object from the given window.
warning Deprecated | use window#getSelection instead. |
---|
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
AbstractRange.isNativeControlRange( range ) → boolean
boolean