W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2012

Default value of cloneNode() parameter

From: Aryeh Gregor <ayg@aryeh.name>
Date: Mon, 20 Feb 2012 12:39:15 -0500
Message-ID: <CAKA+Ax=ksf_BGprEzrmFYepWNyhq9eB7=oDaXLy7KqAmj=OMcw@mail.gmail.com>
To: Anne van Kesteren <annevk@opera.com>, Ms2ger <ms2ger@gmail.com>, Adam Barth <w3c@adambarth.com>, Alexey Proskuryakov <ap@webkit.org>, www-dom@w3.org
WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=78887
Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=698381

Node.cloneNode() takes a boolean parameter, where true means it clones
all descendants too, and false means it doesn't.  DOM4 says the
parameter defaults to true, IE10 Developer Preview and Chrome 18 dev
default to true, and Firefox 13.0a1 and Opera Next 12.00 alpha make
the parameter mandatory.  IE10 also makes it default to false in IE7
browser mode and quirks document mode.  I just changed the spec to
require false, but Ms2ger and Anne disagreed, so I changed it back.
The arguments for requiring a default parameter of true are

1) cloneNode(false) isn't very useful, and is perhaps surprising, so
it would be better to make the parameter mandatory than to make it
default to false.

2) It's inconsistent with the second parameter of importNode(), which
defaults to true in both Gecko and WebKit, and is mandatory in IE and

We clearly don't want cloneNode() and importNode() inconsistent, and
cloneNode(true) is likely more useful, so defaulting it to true makes
more sense.  But going against browsers isn't a great idea either.
Currently n.cloneNode() will either throw, or do something consistent
cross-browser (albeit maybe not so useful).  If some browsers make it
default to true instead of false, it will now silently do something
different in different browsers, which is IMO significantly worse.

Are IE or WebKit willing to change their default?  Would Gecko or
Opera prefer to default to true instead of matching IE/WebKit?
Implementer feedback requested.
Received on Monday, 20 February 2012 17:40:08 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:18 UTC