[whatwg] DOM Range Deletions

Andrew Oakley andrew at ado.is-a-geek.net
Tue Jun 15 03:52:12 PDT 2010


I've been trying to implement DOM Range but can't work out how ranges
are supposed to work under mutation.

In the following examples I use *this* to indicate a range being deleted
and slashes to indicate another range.


Section 2.6 - Deleting Content with a Range gives the example of

<FOO>X*Y<BAR>Z*W</BAR>Q</FOO> -> <FOO>X^<BAR>W</BAR>Q</FOO>


Section 2.12.2 - Deletions says:

"If a boundary-point of the original Range is within the content being
deleted, then after the deletion it will be at the same position as the
resulting boundary-point of the (now collapsed) Range used to delete the
contents."

We then have the example of:

<P>ABCD *efgh The <EM>R*ange</EM> ijkl</P>
              /            \

Goes to

<P>ABCD <EM>ange</EM> ijkl</P>
           /    \

I assume that the range indicated by the underline in the spec and like
*this* here collapses to just before the <EM> tag as this document has
the same structure as the other example I pulled out of the spec.  This
would mean that the start point of the other range should also be just
before the <EM>, but that isn't what has happened in this example.

Any idea what I've got wrong?  Some browsers (e.g. Safari) seem to
behave as in the example, others (e.g. Firefox) put the end point before
the <EM> (as I would have expected).

Thanks

-- 
Andrew Oakley




More information about the whatwg mailing list