The root of the DOM tree to which this DLoc applies.
The node of the location.
The offset of the location.
The node of the location.
The offset of the location.
The root of the DOM tree to which this DLoc applies.
This is the node to which this location points. For locations pointing to
attributes and text nodes, that's the same as node. For locations
pointing to an element, that's the child to which the node, offset
pair
points. Since this pair may point after the last child of an element, the
child obtained may be undefined
.
Creates a copy of the location.
Compare two locations. Note that for attribute ordering, this class
arbitrarily decides that the order of two attributes on the same element is
the same as the order of their name
fields as if they were sorted in an
array with Array.prototype.sort()
. This differs from how
Node.compareDocumentPosition
determines the order of attributes. We
want something stable, which is not implementation dependent. In all other
cases, the nodes are compared in the same way
Node.compareDocumentPosition
does.
The other location to compare this one with.
0
if the locations are the same. -1
if this location comes
first. 1
if the other location comes first.
Whether this
and other
are equal. They are equal if they
are the same object or if they point to the same location.
Same as getLocationInParent except that the location points after the current node.
The location in the parent, as described above.
Make a new location. Let's define "current node" as the node of the current location. The new location points to the current node. (The offset of the current location is effectively ignored.) That is, the new location has for node the parent node of the current node, and for offset the offset of the current node in its parent.
The location in the parent, as described above.
Verifies whether the DLoc
object points to a valid location. The
location is valid if its node
is a child of its root
and if its
offset
points inside the range of children of its node
.
Whether the object is valid.
Make a range from this location. If other
is not specified, the range
starts and ends with this location, and the return value is a range. If
other
is specified, the range goes from this location to the other
location. If other
comes before this
, then the range is
"reversed". When other
is specified, the return value is an object (see
below). (An undefined value for other
is interpreted as an unspecified
other
.)
The return value is just a range when the method is called without
other
. Otherwise, it is a range info object. The return value is
undefined
if either this
or other
is invalid.
Make a new location with the same node as the current location but with a new offset.
The offset of the new location.
The new location.
Like makeDLocRange but throws if it cannot make a range, rather than
return undefined
.
Creates a new DLoc
object with an offset that is valid. It does this by
"normalizing" the offset, i.e. by setting the offset to its maximum
possible value.
The normalized location. This will be this
, if it so happens
that this
is already valid.
Converts the location to an array. This array contains only the node and offset of the location. The root is not included because this method is of use to pass data to functions that work with raw DOM information. These functions do not typically expect a root.
The node and offset pair.
Makes a location.
The root of the DOM tree to which this location belongs.
The node of the location.
The offset of the location. If the offset is omitted, then
the location will point to node
rather than be a location that points
to the node inside of node
at offset offset
.
Whether to normalize the offset to a valid value.
The location. It returns undefined
if the node
is "absent"
because it is undefined
or null
. This is true irrespective of the
signature used. If you use a Caret and it has an absent node, then the
result is undefined
.
Same as DLoc.makeDLoc but must does not accept an "absent" node, and
won't ever return undefined
.
Generated using TypeDoc
DLoc
objects model locations in a DOM tree. Although the current implementation does not enforce this, these objects are to be treated as immutable. These objects havenode
andoffset
properties that are to be interpreted in the same way DOM locations usually are: thenode
is the location of a DOMNode
in a DOM tree (or an attribute), andoffset
is a location in that node.DLoc
objects are said to have aroot
relative to which they are positioned.A DLoc object can point to an offset inside an
Element
, inside aText
node or inside anAttr
.Use makeDLoc to make
DLoc
objects. Calling this constructor directly is not legal.