Re: range.surroundContents

On 1 Jun 2000, at 4:27, Jonas Sicking wrote:

> 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?

surroundContents is a convenience function designed for use with 
well-formed subtrees. Given that, the fix-ups that occur when you 
go through the steps seem to not be intuitive. If you really want to 
be able to, in effect, surround a non-well-formed subtree, you can 
go through the steps and let the automatic fix-ups happen. 
Hopefully the results won't then seem as non-intuitive.

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

Attributes aren't children of an element. They are assoicated with 
an element.


Lauren

Received on Tuesday, 27 June 2000 14:37:32 UTC