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

Re: [whatwg] Confusion about node1.replace(node2)

From: Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net>
Date: Tue, 10 Feb 2015 05:45:24 +0100
To: Bjoern Hoehrmann <derhoermi@gmx.net>, Glen Huang <curvedmark@gmail.com>
Message-ID: <87twyupe6z.fsf@dieweltistgarnichtso.net>
Cc: whatwg@whatwg.org
Bjoern Hoehrmann <derhoermi@gmx.net> writes:

> * Glen Huang wrote:
>>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.
> To illustrate this, imagine some team sports game where the coach jells
> "Jane, replace John!", in other words, `Jane.replace(John)`. It is clear
> that Jane is instructed to take the position of John.

To elaborate on this a bit: “Jane.replace(John)” takes Jane as the first
(implicit) argument and John as the second (explicit), so I read it like
“replace Jane and John”. This may look ambiguous – until you remember
who is instructed to to the replacement, namely Jane.

Nils Dagsson Moskopp // erlehmann
Received on Tuesday, 10 February 2015 04:46:04 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:27 UTC