W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2001

Range extractContents and removeContents algorithms

From: Jeff Yates <PBWiz@PBWizard.com>
Date: Fri, 16 Mar 2001 14:03:02 -0500
Message-ID: <008401c0ae4b$ba742d10$0100a8c0@pbwizshop>
To: <www-dom@w3.org>
I have run into an example not covered in the DOM-Range recommendation on range removal.  The examples given in the recommendation are:

(1) <FOO>AB<MOO>CD</MOO>CD</FOO>  -->

(2) <FOO>A<MOO>BC</MOO>DE</FOO>  -->

(3) <FOO>XY<BAR>ZW</BAR>Q</FOO>  -->

<FOO><BAR1>AB</BAR1><BAR2/><BAR3>CD</BAR3></FOO> -->

These are good examples but does not cover the following circumstance:<FOO>AB<MOO>CD</MOO>CD</FOO><FOO>AB<MOO>CD</MOO>CD</FOO>Notice how the range selects across elements with the same tag name.  There are two ways this rangecould be removed from the source and the recommendation does not specify with method should be used.Method 1:  Cut it out like it was text making sure all of the tags are properly closed:<FOO>AB<MOO>CD</MOO>CD</FOO>Method 2:  Remove only those portions of each element that are in the range:<FOO>AB<MOO>C</MOO></FOO><FOO><MOO>D</MOO>CD</FOO>In my opinion the first method is preferable and is correct, but is left unclear.  A situation that raises questions about method 1 id if the first <FOO> element has different attributes than the second one.  Should the element then be removed?  Also if the second element has event listeners and the first one did not have the same event listeners the events would be lost.  Please clarify this situation.Jeff Yatese-mail:    PBWiz@PBWizard.comHomepage:  http://www.PBWizard.com
Received on Friday, 16 March 2001 14:05:53 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:08 UTC