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

Re: Improving the DOM

From: Simon Pieters <simonp@opera.com>
Date: Wed, 09 Nov 2011 08:42:42 +0100
To: "Ojan Vafai" <ojan@chromium.org>, "Jonas Sicking" <jonas@sicking.cc>
Cc: "Anne van Kesteren" <annevk@opera.com>, "Jake Verbaten" <raynos2@gmail.com>, www-dom@w3.org
Message-ID: <op.v4n41gp9idj3kv@simon-pieterss-macbook.local>
On Wed, 09 Nov 2011 02:19:00 +0100, Jonas Sicking <jonas@sicking.cc> wrote:

> I think .before, .after and .remove should be available on all nodes
> which can appear in the normal document tree, including PIs and

PI is CharacterData in DOM4.

> DocTypes. There's no reason to be inconsistent here and it'll just
> make it annoying for people that are iterating over the tree and
> perform operations on it. I agree that DocTypes/PIs aren't commonly
> used, but they do appear in the DOM now and then and it makes it even
> worse for authors if they have to explicitly handle those types of
> nodes different.
>
> As for .append and .prepend, I think we should make those exist on all
> nodes which can have children, including Documents. This for the same
> reason, it makes things more consistent for authors.
>
> I don't think it's our job to pass judgement on what nodes people
> should or should not be modifying or having in their DOM.
>
> / Jonas

I agree.

One use case could be to replace everything in a document with new nodes:

while (document.hasChildNodes())
   document.firstChild.remove();
document.append(newroot);

-- 
Simon Pieters
Opera Software
Received on Wednesday, 9 November 2011 07:41:21 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:08 GMT