Bug 11646 - Implement Document.cloneNode()
Summary: Implement Document.cloneNode()
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 420+
Hardware: All All
: P2 Enhancement
Assignee: Ryosuke Niwa
Keywords: BlinkMergeCandidate
: 119928 125285 (view as bug list)
Depends on:
Blocks: 10489
  Show dependency treegraph
Reported: 2006-11-18 16:56 PST by Jesse Costello-Good
Modified: 2019-02-06 09:03 PST (History)
16 users (show)

See Also:

Fixes the bug (16.05 KB, patch)
2013-12-09 10:39 PST, Ryosuke Niwa
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Costello-Good 2006-11-18 16:56:03 PST
This method currently returns null.
Comment 1 Alexey Proskuryakov 2006-11-19 00:57:50 PST
Per the DOM spec, "cloning Document, DocumentType, Entity, and Notation nodes is implementation dependent." I couldn't find any Mozilla documentation either, so we may have to reverse-engineer it.
Comment 2 Jesse Costello-Good 2006-12-01 16:16:53 PST
A perhaps non-obvious feature of this method is that if the target of the clone() method has a node <xsl:import href="">, the cloned document should be able to resolve the href attribute in the same way that the target would. In other words, the cloned document needs to behave the same as if it had been loaded from the same URL as the target document.

Related bug: http://bugs.webkit.org/show_bug.cgi?id=10313
Comment 3 Alexey Proskuryakov 2013-08-19 09:32:25 PDT
*** Bug 119928 has been marked as a duplicate of this bug. ***
Comment 5 Alexey Proskuryakov 2013-12-05 00:13:34 PST
*** Bug 125285 has been marked as a duplicate of this bug. ***
Comment 6 Ryosuke Niwa 2013-12-09 10:39:39 PST
Created attachment 218776 [details]
Fixes the bug
Comment 7 Darin Adler 2013-12-09 11:30:14 PST
Comment on attachment 218776 [details]
Fixes the bug

View in context: https://bugs.webkit.org/attachment.cgi?id=218776&action=review

> Source/WebCore/dom/Document.cpp:3039
> +    return isXHTMLDocument() ? createXHTML(0, url()) : create(0, url());

nullptr please, not 0

> Source/WebCore/html/HTMLDocument.cpp:370
> +    return create(0, url());

nullptr please, not 0

> Source/WebCore/svg/SVGDocument.cpp:105
> +    return create(0, url());

nullptr please, not 0

> Source/WebCore/svg/SVGDocument.h:56
> +    virtual PassRefPtr<Document> cloneDocumentWithoutChildren() const OVERRIDE FINAL;

Class is FINAL so no need to mark function FINAL, but I suppose there’s no harm in it.
Comment 8 Ryosuke Niwa 2013-12-09 14:03:43 PST
Committed r160330: <http://trac.webkit.org/changeset/160330>
Comment 9 Lucas Forschler 2019-02-06 09:03:48 PST
Mass moving XML DOM bugs to the "DOM" Component.