Range extension type

The Range interface represents a fragment of a document that can contain nodes and parts of text nodes.

A range can be created by using the Document.createRange method. Range objects can also be retrieved by using the Selection/getRangeAt method of the Selection object or the Document/caretRangeFromPoint method of the Document object.

There also is the Range.Range constructor available.

on
Implemented types

Constructors

Range()
factory

Properties

collapsed bool
no setterinherited
commonAncestorContainer Node
no setter
endContainer Node
no setterinherited
endOffset int
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startContainer Node
no setterinherited
startOffset int
no setterinherited

Methods

cloneContents() DocumentFragment
The Range.cloneContents() returns a DocumentFragment copying the objects of type Node included in the Range.
cloneRange() Range
The Range.cloneRange() method returns a Range object with boundary points identical to the cloned Range.
collapse([bool toStart]) → void
The Range.collapse() method collapses the Range to one of its boundary points.
compareBoundaryPoints(int how, Range sourceRange) int
The Range.compareBoundaryPoints() method compares the boundary points of the Range with those of another range.
comparePoint(Node node, int offset) int
The Range.comparePoint() method returns -1, 0, or 1 depending on whether the referenceNode is before, the same as, or after the Range.
createContextualFragment(String fragment) DocumentFragment
The Range.createContextualFragment() method returns a DocumentFragment by invoking the HTML fragment parsing algorithm or the XML fragment parsing algorithm with the start of the range (the parent of the selected node) as the context node. The HTML fragment parsing algorithm is used if the range belongs to a Document whose HTMLness bit is set. In the HTML case, if the context node would be html, for historical reasons the fragment parsing algorithm is invoked with body as the context instead.
deleteContents() → void
The Range.deleteContents() method removes the contents of the Range from the Document.
detach() → void
The Range.detach() method does nothing. It used to disable the Range object and enable the browser to release associated resources. The method has been kept for compatibility.
extractContents() DocumentFragment
The Range.extractContents() method moves contents of the Range from the document tree into a DocumentFragment.
getBoundingClientRect() DOMRect
The Range.getBoundingClientRect() method returns a DOMRect object that bounds the contents of the range; this is a rectangle enclosing the union of the bounding rectangles for all the elements in the range.
getClientRects() DOMRectList
The Range.getClientRects() method returns a list of DOMRect objects representing the area of the screen occupied by the range. This is created by aggregating the results of calls to Element.getClientRects for all the elements in the range.
insertNode(Node node) → void
The Range.insertNode() method inserts a node at the start of the Range.
intersectsNode(Node node) bool
The Range.intersectsNode() method returns a boolean indicating whether the given Node intersects the Range.
isPointInRange(Node node, int offset) bool
The Range.isPointInRange() method returns a boolean indicating whether the given point is in the Range. It returns true if the point (cursor position) at offset within ReferenceNode is within this range.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
selectNode(Node node) → void
The Range.selectNode() method sets the Range to contain the Node and its contents. The parent Node of the start and end of the Range will be the same as the parent of the referenceNode.
selectNodeContents(Node node) → void
The Range.selectNodeContents() method sets the Range to contain the contents of a Node.
setEnd(Node node, int offset) → void
The Range.setEnd() method sets the end position of a Range to be located at the given offset into the specified node x.Setting the end point above (higher in the document) than the start point will result in a collapsed range with the start and end points both set to the specified end position.
setEndAfter(Node node) → void
The Range.setEndAfter() method sets the end position of a Range relative to another Node. The parent Node of end of the Range will be the same as that for the referenceNode.
setEndBefore(Node node) → void
The Range.setEndBefore() method sets the end position of a Range relative to another Node. The parent Node of end of the Range will be the same as that for the referenceNode.
setStart(Node node, int offset) → void
The Range.setStart() method sets the start position of a Range.
setStartAfter(Node node) → void
The Range.setStartAfter() method sets the start position of a Range relative to a Node. The parent Node of the start of the Range will be the same as that for the referenceNode.
setStartBefore(Node node) → void
The Range.setStartBefore() method sets the start position of a Range relative to another Node. The parent Node of the start of the Range will be the same as that for the referenceNode.
surroundContents(Node newParent) → void
The Range.surroundContents() method moves content of the Range into a new node, placing the new node at the start of the specified range.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

END_TO_END int
no setter
END_TO_START int
no setter
START_TO_END int
no setter
START_TO_START int
no setter