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

[whatwg] cloneNode and HTML elements

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Thu, 10 Sep 2009 12:01:43 +0300
Message-ID: <4AA8C077.3040505@helsinki.fi>
On 9/10/09 11:13 AM, Jonas Sicking wrote:
> On Thu, Sep 10, 2009 at 12:41 AM, Maciej Stachowiak<mjs at apple.com>  wrote:
>>
>> On Sep 9, 2009, at 10:26 PM, Robert O'Callahan wrote:
>>
>>> If you call cloneNode on a media element, the state of the resulting media
>>> element seems unspecified. Should it be playing the same media resource at
>>> the same current time as the original?
>>>
>>> Similar questions arise when you clone form elements; is the state that's
>>> not visible in the DOM cloned?
>>>
>>> Who should be responsible for defining this?
>>
>> Does cloneNode require copying any state besides an element's qualified
>> name, attributes and DOM children? The definition in DOM3Core doesn't say
>> anything else should be copied. Is form control state (such as set of items
>> selected in a<list multiple>) copied?
>>
>> 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.
>
> My assumption was always the opposite. For example for<input>
> elements we clone the 'value' API attribute, as well as the internal
> has-changed-value bit (used for form field restore when going back to
> a page). For<script>  we copy over the has-executed bit. I'm fairly
> sure that the list is longer.
>
> / Jonas
>

I've always interpret DOM3 Core strictly; cloning an element
clones the object and "copies all attributes and their values"
So no state copying.
(I noticed the input element state cloning when writing
  other cloning related stuff.)

If we start to copy the state, there is the problem to define what all 
state should be cloned.

Btw, DOM 3 Core defines it pretty badly what should be cloned when a 
document is cloned. "cloning Document ... is implementation dependent"

If elements start to clone their state, should document do it too.
Should document's stylesheets be cloned? And if stylesheets, what about
.defaultView etc. ?



-Olli
Received on Thursday, 10 September 2009 02:01:43 UTC

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