Bug 11646

Summary: Implement Document.cloneNode()
Product: WebKit Reporter: Jesse Costello-Good <jesse>
Component: DOMAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Enhancement CC: ap, arv, cdumez, commit-queue, d-r, esprehn+autocc, fmalita, gyuyoung.kim, kangil.han, kling, koivisto, mail, pdr, rniwa, schenney, syoichi
Priority: P2 Keywords: BlinkMergeCandidate
Version: 420+   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 10489    
Attachments:
Description Flags
Fixes the bug darin: review+

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.