Re: Default value of cloneNode() parameter

On 02/20/2012 07:39 PM, Aryeh Gregor wrote:
> 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
> Opera.
>
> 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.
>

I do prefer true, both because of consistency and because of
more useful API.

(my guess is that webkit defaults to false just because it hasn't
traditionally required parameters to be there and non-existing boolean
has implicitly got false as value. Just like with 3rd parameter of
addEventListener)



-Olli

Received on Monday, 20 February 2012 17:47:39 UTC