W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2008

Re: DOM2 - Range- ambiguity in surroundContents exceptions

From: Philippe Le Hegaret <plh@w3.org>
Date: Mon, 09 Jun 2008 16:24:58 +0000
To: Germain Garand <germain@ebooksfrance.org>
Cc: www-dom@w3.org
Message-Id: <1213028698.2929.46.camel@localhost>

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>]E</BAR>
> "
> (emphasis of Range with [] characters)
> 
> Greetings,
> Germain
Received on Monday, 9 June 2008 16:25:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:59 GMT