range.surroundContents

Hi!

DOM2 CR section 8.10 [1] says that if you apply the surroundContents method
to the following range (stars marking range start and end):

<FOO>A*B<BAR>C*D</BAR>E</FOO>

An exception should be thrown.
However, if you follow the steps described a bit further up in the same
section you would get the following DOM tree:

<FOO>A*<NEW>B<BAR>C</BAR></NEW>*<BAR>D</BAR>E</FOO>

Which I think is the most useful result. Is there a reason that an exception
should be thrown?

Also, the CR says that all children of the new node should be deleted before
the node is inserted. Couldn't it be useful to allow attribute nodes to
remain.  In other words allowing operations like:

Before:
<FOO>*ABC*</FOO>
After:
<FOO>*<BAR a="b">ABC</BAR>*</FOO>

[1] http://www.w3.org/TR/DOM-Level-2/range.html#Level-2-Range-Surrounding

/ Jonas Sicking

Received on Wednesday, 31 May 2000 22:26:43 UTC