W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2015

[whatwg] Confusion about node1.replace(node2)

From: Glen Huang <curvedmark@gmail.com>
Date: Sat, 10 Jan 2015 15:26:28 +0800
Message-Id: <F368C765-8FF5-468B-8CC6-969A76B2BF5E@gmail.com>
To: whatwg@whatwg.org
Currently the DOM spec defines a replace() method in the ChildNode interface. I find the name for that method a bit misleading.

When someone says A replace B, I get the impression that B is no longer in effect and A is the new one. So when I do `node1.replace(node2)`, I can’t help but feel node2 is replaced with node1, which is the opposite of what the spec specifies.

Do you think it would be worthwhile to change to a name that states the intention a bit clearer? Maybe something like `node1.replacedWith(node2)`?
Received on Saturday, 10 January 2015 08:16:56 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:32 UTC