DOM
SourceIn all current engines.
Firefox69+Safari10.1+Chrome60+ Opera47+Edge79+ Edge (Legacy)18IENone Firefox for AndroidNoneiOS Safari10.3+Chrome for Android60+Android WebView60+Samsung Internet8.0+Opera Mobile44+
dictionaryStaticRangeInit
{ required NodestartContainer
; required unsigned longstartOffset
; required NodeendContainer
; required unsigned longendOffset
; }; [Exposed=Window] interfaceStaticRange
: ); };
staticRange = new StaticRange(init)
Returns a new range object that does not update when the node tree mutates.
Firefox71+Safari13.1+ChromeNone OperaNoneEdgeNone Edge (Legacy)NoneIENone Firefox for AndroidNoneiOS Safari13.4+Chrome for AndroidNoneAndroid WebViewNoneSamsung InternetNoneOpera MobileNone
The new StaticRange(init)
constructor steps are:
In all current engines.
Firefox1+Safari1+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
[Exposed=Window]
interface Range
: , ); , ); ); ); ); ); = false); ); ); const , ); [); [); [, ); , ); ); stringifier;
};
Objects implementing the Range
interface are known as live ranges.
Algorithms that modify a tree (in particular the insert, remove, replace data, and split algorithms) modify live ranges associated with that tree.
The root of a live range is the root of its start node.
A node node is contained in a live range range if node’s root is range’s root, and (node, 0) is after range’s start, and
(node, node’s length) is before range’s end.
A node is partially contained in a live range if it’s an inclusive ancestor of the live range’s start node but not its end node, or vice versa.
Some facts to better understand these definitions:
-
The content that one would think of as being within the live range consists of all contained nodes, plus possibly some of the contents of the start node and end node if those are
Text
,ProcessingInstruction
, orComment
nodes. -
The nodes that are contained in a live range will generally not be contiguous, because the parent of a contained node will not always be contained.
-
However, the descendants of a contained node are contained, and if two siblings are contained, so are any siblings that lie between them.
-
The start node and end node of a live range are never contained within it.
-
The first contained node (if there are any) will always be after the start node, and the last contained node will always be equal to or before the end node’s last descendant.
-
There exists a partially contained node if and only if the start node and end node are different.
-
The
commonAncestorContainer
attribute value is neither contained nor partially contained. -
If the start node is an ancestor of the end node, the common inclusive ancestor will be the start node. Exactly one of its children will be partially contained, and a child will be contained if and only if it precedes the partially contained child. If the end node is an ancestor of the start node, the opposite holds.
-
If the start node is not an inclusive ancestor of the end node, nor vice versa, the common inclusive ancestor will be distinct from both of them. Exactly two of its children will be partially contained, and a child will be contained if and only if it lies between those two.
range = new Range()
Returns a new live range. In all current engines.
Firefox24+Safari6.1+Chrome29+ Opera16+Edge79+ Edge (Legacy)15+IENone Firefox for Android24+iOS Safari8+Chrome for Android29+Android WebView37+Samsung Internet2.0+Opera Mobile16+
The new Range()
constructor steps are
to set this’s start and end to
(current global object’s associated Document
, 0).
commonAncestorContainer
Returns the node, furthest away from the document, that is an ancestor of both range’s start node and end node. Read Next page