Section 25.234. Range.compareBoundaryPoints(): compare positions of two ranges


25.234. Range.compareBoundaryPoints(): compare positions of two ranges

DOM Level 2 Range

25.234.1. Synopsis

 short compareBoundaryPoints(unsigned short how,                             Range sourceRange)     throws DOMException; 

25.234.1.1. 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.

25.234.1.2. 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.

25.234.1.3. 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.

25.234.2. 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 return value of this method is a number that specifies the relative position of this range to the specified sourceRange. Therefore, you might expect the range constants for the how argument to specify the boundary point for this range first and the boundary point for sourceRange second. Counterintuitively, however, the Range.START_TO_END constant specifies a comparison of the end point of this range with the start point of the specified sourceRange. Similarly, the Range.END_TO_START constant specifies a comparison of the start point of this range with the end point of the specified range.




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net