W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2009

[whatwg] cloneNode and HTML elements

From: Maciej Stachowiak <mjs@apple.com>
Date: Thu, 10 Sep 2009 04:45:42 -0700
Message-ID: <5F62678E-90DD-439F-B75A-E435944A416F@apple.com>

On Sep 10, 2009, at 2:15 AM, Robert O'Callahan wrote:

> On Thu, Sep 10, 2009 at 7:41 PM, Maciej Stachowiak <mjs at apple.com>  
> wrote:
>
> Reference for cloneNode:
> http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-3A0ED0A4
>
> My assumption based on the spec is that no element-specific internal  
> state should be copied, the cloning should only be DOM-wise.
>
> It's not obvious to me that DOM 3 Core's silence means nothing else  
> is copied,

That's how I would tend to interpret its silence, unless some other  
spec says otherwise.  But to be fair, a the DOM specs are sometimes  
vague on the details. For example, it doesn't explicitly say what  
localName, prefix or namespace a cloned element gets. Or that what  
text contents cloned Text nodes should have.


> since non-DOM state is outside its scope.

DOM2 Core also defines cloneNode, and the associated DOM2 HTML does  
not impose any additional requirements for the HTML elements that have  
internal state. That would tend to support the theory that copying  
element-specific non-DOM state was not intended.

>
> I wonder if authors would be surprised if the non-DOM state is not  
> copied.

We haven't had any bug reports about it in WebKit, and we don't clone  
any internal state. We do have a bug report on cloneNode for  
Documents, where our choice of implementation-defined behavior is to  
return null. We'll likely have to fix that.

My mental model of cloneNode is that it's equivalent to creating a  
brand new element with the right name and namespace, adding the  
appropriate attributes, and if a deep clone, copies of its children.  
So I would not be surprised. Others may have a different mental model.


Regards,
Maciej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090910/28f86990/attachment.htm>
Received on Thursday, 10 September 2009 04:45:42 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:52 UTC