[dom] The "replace" algorithm doesn't deal with the case when child == node.prevSibling

I'm looking at 
http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-replace

Assume that on entry child == node.prevSibling.

In step 6, we set "reference child" to "node".

In step 7, we remove "node" from "parent".

In step 8, we remove "child" from "parent"

In step 9 we're supposed to "Insert node into parent before reference 
child with the suppress observers flag set.".  But "reference child" == 
"node", and it's no longer a child of "parent", as of step 7.  It's not 
clear to me what's actually supposed to happen in this case; the 
algorithm at 
http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-insert 
seems to assume that "child" is a child of "parent".

Perhaps what should happen is that in step 6.5 if "reference child" is 
set to "node" it should be set to node.nextSibling?  What do UAs do?

-Boris

P.S.  Actually, 
http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-pre-insert 
has a similar problem when "node" == "child".  Step 6 removes "node" 
(and hence "child") from "parent".  Step 7 tries to "Insert node into 
parent before child", but it's not clear how that's supposed to work in 
that situation.  Again, using a reference child which is child unless 
child == node, in which case it's child.nextSibling should probably fix 
the situation.

Received on Saturday, 2 June 2012 02:59:41 UTC