W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2001

Range.compareBoundaryPoints() is counter-intuitive

From: David Flanagan <david@oreilly.com>
Date: Sun, 12 Aug 2001 14:43:33 -0700
Message-Id: <200108122143.OAA01141@oxymoron.oreilly.com>
To: www-dom@w3.org

I've just written the following paragraph for the description of
Range.compareBoundaryPoints() in my JavaScript book.  If anyone
disagrees with my assessment of compareBoundaryPoints() as
counter-intuitive, please help me understand why it is not.  I believe
I'm describing the spec as it is written and as it is implemented by
Mozilla.  (Note, that I'm not proposing that the spec be modified in
anyway: I just want to verify that I'm correctly interpreting its
counter-intuitive nature.)

	David Flanagan
--------------------------

      The return value of this method is a number that specifies the
      relative position of this Range to the specified
      <replaceable>sourceRange</replaceable>.  Therefore, you might
      expect the Range constants for the <replaceable>how</replaceable>
      argument to specify the boundary point for this range first and
      the boundary point for <literal>sourceRange</literal> second.
      Counter-intuitively, however, the sense of the return value and
      the <replaceable>how</replaceable> constants are opposite of one
      another, and the <literal>Range.START_TO_END</literal> contant
      specifies a comparison of the <emphasis>end</emphasis> point of
      this range with the <emphasis>start</emphasis> point of the
      specified <replaceable>sourceRange</replaceable>.  Similarly, the
      <literal>Range.END_TO_START</literal> constant specifies a
      comparison of the <emphasis>start</emphasis> point of this range
      with the <emphasis>end</emphasis> point of the specified range.
Received on Sunday, 12 August 2001 18:37:54 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:49 GMT