Name
Range.compareBoundaryPoints(): compare positions of two ranges — DOM Level 2 Range
Synopsis
short compareBoundaryPoints(unsigned shorthow, RangesourceRange) throws DOMException;
Arguments
-
how Specifies how to perform the comparison (i.e., which boundary points to compare). Legal values are the constants defined by the Range interface.
-
sourceRange The range that is to be compared to this range.
Returns
The value −1 if the specified boundary point of this range
is before the specified boundary point of
sourceRange, 0 if the two specified
boundary points are the same, or 1 if the specified boundary point
of this range is after the specified boundary point of
sourceRange.
Throws
If sourceRange represents a range
of a different document than this range does, this method throws a
DOMException with a code of
WRONG_DOCUMENT_ERR.
Description
This method compares a boundary point of this range to a
boundary point of the specified
sourceRange and returns a value that
specifies their relative order in the document source. The
how argument specifies which boundary
points of each range are to be compared. The legal values for this
argument, and their meanings, are as follows:
-
Range.START_TO_START Compares the start points of the two Range nodes.
-
Range.END_TO_END Compares the end points of the two Range nodes.
-
Range.START_TO_END Compares the start point of
sourceRangeto the end point of this range.-
Range.END_TO_START Compares the end point of
sourceRangeto the start point of this range.
The return ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access