List Info

Thread: Re: DOM2 - Range- ambiguity in surroundContents exceptions




Re: DOM2 - Range- ambiguity in surroundContents exceptions
country flaguser name
United States
2008-06-09 11:24:58
My take is that you are correct.

In the case where the container is CharacterData, Comment,
or
ProcessingInstruction, the exception should only be raised
if the
immediate ancestor of the container of the start of the
Range is of a
type that does not allow children of the type of newParent.
The goal
being that the operation insertNode() should succeed in
order for
surroundContents to succeed as well.

Even insertNode(), while being clear in its description that
the Text
node split in two, fails to address this case in its
description of the
exception. In effect, the container of the start of the
Range is
effectively modified prior to the insertion.

In addition, insertNode only mentions Text nodes but forgets
about
ProcessingInstruction or Comment nodes.

Philippe

On Thu, 2008-04-03 at 14:04 +0200, Germain Garand wrote:
> I believe there is an ambiguity in the way the
HIERARCHY_REQUEST_ERR exception 
> is defined for the DOM Level2 Range's surroundContents
method:
> 
> "HIERARCHY_REQUEST_ERR: Raised if the container of
the start of the Range is 
> of a type that does not allow children of the type of
newParent "
> 
> 2.2.1: "If the container is a CharacterData,
Comment or ProcessingInstruction 
> node, the offset is between the 16-bit units of the
UTF-16 encoded string 
> contained by it."
> 
> It is therefore implied that the 'container' of a
textual boundary point is 
> the text node itself.
> 
> In those conditions, according to the exception
definition, surrounding a 
> textual range X with an element node Y should raise, as
Y (newParent) is of a 
> type that is not allowed in the container of the start
of the Range X.
> 
> at the same time, the examples of 2.10 make clear that
such a surrounding is 
> possible:
> 
> "     Before:
>       
<BAR>A[B<MOO>C</MOO>D]E</BAR>
> 
>      After surroundContents(FOO):
> 
>
<BAR>A[<FOO>B<MOO>C</MOO>D</FOO&g
t;]E</BAR>
> "
> (emphasis of Range with [] characters)
> 
> Greetings,
> Germain



[1]

about | contact  Other archives ( Real Estate discussion Medical topics )