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.
API documentation sourced from MDN Web Docs.
- on
- Implemented types
- Available extensions
Constructors
- Range()
-
factory
Properties
- collapsed → bool
-
The read-only
collapsed
property of the AbstractRange interface returnstrue
if the range's start position and end position are the same.no setterinherited - commonAncestorContainer → Node
-
The
Range.commonAncestorContainer
read-only property returns the deepest — or furthest down the document tree — Node that contains both boundary points of the Range. This means that if Range.startContainer and Range.endContainer both refer to the same node, this node is the common ancestor container.no setter - endContainer → Node
-
The read-only
endContainer
property of the AbstractRange interface returns the Node in which the end of the range is located.no setterinherited - endOffset → int
-
The
endOffset
property of the AbstractRange interface returns the offset into the end node of the range's end position.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- isDefinedAndNotNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
no setter - isNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
Whether this value corresponds to JavaScriptnull
.no setter - isTruthy → JSBoolean
-
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of!!
in JavaScript.this
no setter - isUndefined → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
Whether this value corresponds to JavaScriptundefined
.no setter - isUndefinedOrNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
no setter - not → JSBoolean
-
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of!
in JavaScript.this
no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startContainer → Node
-
The read-only
startContainer
property of the AbstractRange interface returns the start Node for the range.no setterinherited - startOffset → int
-
The read-only
startOffset
property of the AbstractRange interface returns the offset into the start node of the range's start position.no setterinherited
Methods
-
add(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
+any
-
and(
JSAny? any) → JSAny? -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
&&any
-
callMethod<
R extends JSAny?> (JSAny method, [JSAny? arg1, JSAny? arg2, JSAny? arg3, JSAny? arg4]) → R -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Callsmethod
on this JSObject with up to four arguments. -
callMethodVarArgs<
R extends JSAny?> (JSAny method, [List< JSAny?> ? arguments]) → R -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Callsmethod
on this JSObject with a variable number ofarguments
. -
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
, or1
depending on whether thereferenceNode
is before, the same as, or after the Range. -
createContextualFragment(
JSAny string) → 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 aDocument
whose HTMLness bit is set. In the HTML case, if the context node would behtml
, for historical reasons the fragment parsing algorithm is invoked withbody
as the context instead. -
dartify(
) → Object? -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Converts a JavaScript value to the Dart equivalent if possible. -
delete(
JSAny property) → JSBoolean -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Deletes the property with keyproperty
from this JSObject. -
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. -
divide(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
/any
-
equals(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
==any
-
exponentiate(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
**any
-
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. -
getProperty<
R extends JSAny?> (JSAny property) → R -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
The value of the property keyproperty
of this JSObject. -
greaterThan(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
>any
-
greaterThanOrEqualTo(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
>=any
-
has(
String property) → bool -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Shorthand helper for hasProperty to check whether this JSObject contains the property keyproperty
, but takes and returns a Dart value. -
hasProperty(
JSAny property) → JSBoolean -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Whether or not this JSObject contains the property keyproperty
. -
insertNode(
Node node) → void -
The
Range.insertNode()
method inserts a node at the start of the Range. -
instanceof(
JSFunction constructor) → bool -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Whether thisJSAny?
is aninstanceof
constructor
. -
instanceOfString(
String constructorName) → bool -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Whether thisJSAny?
is aninstanceof
the constructor that is defined byconstructorName
, which is looked up in the globalContext. -
intersectsNode(
Node node) → bool -
The
Range.intersectsNode()
method returns a boolean indicating whether the given Node intersects the Range. -
isA<
T extends JSAny?> () → bool -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Whether thisJSAny?
is an instance of the JavaScript type that is declared byT
. -
isPointInRange(
Node node, int offset) → bool -
The
Range.isPointInRange()
method returns a boolean indicating whether the given point is in the Range. It returnstrue
if the point (cursor position) atoffset
withinReferenceNode
is within this range. -
lessThan(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
<any
-
lessThanOrEqualTo(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
<=any
-
modulo(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
%any
-
multiply(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
*any
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notEquals(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
!=any
-
or(
JSAny? any) → JSAny? -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
||any
-
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 parentNode
of end of theRange
will be the same as that for thereferenceNode
. -
setEndBefore(
Node node) → void -
The
Range.setEndBefore()
method sets the end position of aRange
relative to another Node. The parentNode
of end of theRange
will be the same as that for thereferenceNode
. -
setProperty(
JSAny property, JSAny? value) → void -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Write thevalue
of property keyproperty
of this JSObject. -
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 thereferenceNode
. -
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 thereferenceNode
. -
strictEquals(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
===any
-
strictNotEquals(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
!==any
-
subtract(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
-any
-
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
-
typeofEquals(
String typeString) → bool -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Whether the result oftypeof
on thisJSAny?
istypeString
. -
unsignedRightShift(
JSAny? any) → JSNumber -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
>>>any
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String property) → JSAny? -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Shorthand helper for getProperty to get the value of the property keyproperty
of this JSObject, but takes and returns a Dart value. -
operator []=(
String property, JSAny? value) → void -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Shorthand helper for setProperty to write thevalue
of the property keyproperty
of this JSObject, but takes a Dart value.
Constants
- END_TO_END → const int
- END_TO_START → const int
- START_TO_END → const int
- START_TO_START → const int