[whatwg] cloneNode and HTML elements
Ian Hickson
ian at hixie.ch
Mon Sep 14 21:11:11 PDT 2009
On Thu, 10 Sep 2009, 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?
Cloning a DOM node is equivalent to serialising it and reparsing it.
Nothing but the element's tag name, prefix, namespace, and attributes is
cloned (plus the children, if the right argument is provided).
The only exception to this is the <script> element, which HTML5 says has
its "already executed" bit cloned also.
> Who should be responsible for defining this?
Web DOM Core should define what cloning does. DOM3 Core does define what I
describe above, though in it's usual non-committal and vague manner.
In general though, nothing ever happens unless specified otherwise, and
nothing specifies that anything but the attributes and the element's own
identity gets cloned.
On Thu, 10 Sep 2009, Olli Pettay wrote:
> 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:
> > >
> > > 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.
>
> 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.)
I didn't even know about the input control state cloning. I've updated the
spec to require that the value, checkedness, dirty value, and dirty
checkedness flags get cloned too.
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list