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

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

From: Brian Kardell <bkardell@gmail.com>
Date: Mon, 12 Jan 2015 16:01:44 -0500
Message-ID: <CADC=+jcEh0n5xRgHksYXdThg-nGGgYkEfDDGAZngsZsDkM48OQ@mail.gmail.com>
To: Glen Huang <curvedmark@gmail.com>
Cc: whatwg <whatwg@whatwg.org>
On Mon, Jan 12, 2015 at 7:15 AM, Glen Huang <curvedmark@gmail.com> wrote:

> Just realize that reversing the algorithm won’t work for
> node.replace(nodes), where nodes contains multiple nodes.
>
> So yeah, replaceWith looks pretty good.
>
> > On Jan 12, 2015, at 8:07 PM, Anne van Kesteren <annevk@annevk.nl> wrote:
> >
> > On Mon, Jan 12, 2015 at 12:03 PM, Glen Huang <curvedmark@gmail.com>
> wrote:
> >> Or, the current algorithm of replace could be reversed, which should
> eliminate such confusion.
> >
> > I think as James said that would leave the confusion. And given the
> > precedent in libraries, replaceWith() seems good.
> >
> >
> > --
> > https://annevankesteren.nl/
>
>

Yeah, libraries seem to have proven this out - unless there is a really
compelling reason to violate this, replaceWith seems to be what it should
be called. +1 to that.

-- 
Brian Kardell :: @briankardell :: hitchjs.com
Received on Monday, 12 January 2015 21:02:10 UTC

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