W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2006


From: Joao Eiras <joao.eiras@gmail.com>
Date: Mon, 04 Sep 2006 23:32:59 +0100
To: www-dom@w3.org
Message-ID: <op.tfdkw9vzxl3at9@dragast>

At http://www.w3.org/DOM/L2CR2comments_public.html

   Issue Core-13:
     Why not Node.insertAfter()
   node.insertAfter(newKid,refChild), if it existed, would be precisely  
equivalent to node.
   insertBefore(newKid,refChild.getNextSibling()).So insertAfter might be  
convenient, but isn't strictly necessary.

This isn't quite correct. There can be no nextSibling.
A implementation of insertAfter (in javascript) would be

   Node.prototype.insertAfter = function (newChild, refChild) {
     if (refChild.nextSibling)
       this.insertBefore(newChild, refChild.nextSibling);
     else if (refChild.parentNode == this)
       throw "NOT_FOUND_ERR";//whatever - refChild isn't child of current  

Since this piece of code is extremely simple, and trivial, there's no  
reason for it not to become part of the DOM core. It's easier than having  
to carry it always around.
Received on Monday, 4 September 2006 22:33:28 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:13 UTC