W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2011

Re: modifying the DOM WAS: Node append

From: Ojan Vafai <ojan@chromium.org>
Date: Mon, 3 Oct 2011 14:54:09 -0700
Message-ID: <CANMdWTsuaF6HrjG_1pzjyv3M2B+2OCnkkZFNovj0O8nw7i4YoA@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: Anne van Kesteren <annevk@opera.com>, Aryeh Gregor <ayg@aryeh.name>, Erik Arvidsson <arv@chromium.org>, Olli@pettay.fi, Robin Berjon <robin@berjon.com>, www-dom@w3.org, Alex Russell <slightlyoff@chromium.org>
On Mon, Oct 3, 2011 at 2:39 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 10/3/11 5:30 PM, Ojan Vafai wrote:
>> Specifically, lets add the following methods to Node:
>> prepend(nodeish) - Adds to the start of the node.
>> append(nodeish) - Adds to the end of the node.
>> before(nodeish) - Adds before the node.
>> after(nodeish) - Adds after the node.
>> replace(nodeish) - Replaces the node.
>> remove() - Removes the node.
> No matter what else, we _have_ to do the remove thing!
> foo.parentNode.removeChild(**foo) is just .... <sigh>.
> The only worry with adding these is on* attributes that might happen to use
> those barewords and expect to hit global scope.  Do we have any data on such
> things?  (Note that we've had problems with that sort of thing in the past,
> e.g. when inputs grew a 'list' property.)

I don't know how we can test for this without just trying it. We could turn
this on only in something like the Chromium dev channel for a few weeks and
see if we get bug reports.

A quick search on Google code search doesn't find anything, which is
promising, but this is a difficult thing to search for.

> 1. node, string, array, nodelist
>> 2. node, string, array, nodelist, number, bool, undefined, null
>> 3. node, string, anything with a length property is treated as an array,
>> anything else is toString'ed.
> And for option 2 anything else throws?

That's what I had in mind.

> Note that in webidl terms, "array", "nodelist", and "anything with a length
> property" are sort of the same thing last I checked....

I'm OK with that. So, a 4th option which is now the one I have preference
for :).

4. node, string, number, bool, undefined, null, anything with a length

> -Boris
Received on Monday, 3 October 2011 21:54:53 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:36:59 UTC