Name

Range.compareBoundaryPoints(): compare positions of two ranges — DOM Level 2 Range

Synopsis

short compareBoundaryPoints(unsigned shorthow,
                            Range sourceRange)
    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 sourceRange to the end point of this range.

Range.END_TO_START

Compares the end point of sourceRange to the start point of this range.

The ...

Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.