From 56ec781aea06ff4bf432685f9ee4d3ede0d8e1ff Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 3 Jun 2022 19:12:15 +0300 Subject: [PATCH] LibWeb: Support DocumentFragments in Node.prototype.cloneNode In this case, "Do nothing" means do nothing *extra* aside from creating a new instance. --- Userland/Libraries/LibWeb/DOM/Node.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 84e82a1e56..eced978f4c 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -668,8 +668,9 @@ NonnullRefPtr Node::clone_node(Document* document, bool clone_children) }); copy = move(element_copy); - } else if (is(this)) { - // 3. Otherwise, let copy be a node that implements the same interfaces as node, and fulfills these additional requirements, switching on the interface node implements: + } + // 3. Otherwise, let copy be a node that implements the same interfaces as node, and fulfills these additional requirements, switching on the interface node implements: + else if (is(this)) { // Document auto document_ = verify_cast(this); auto document_copy = Document::create(document_->url()); @@ -720,6 +721,9 @@ NonnullRefPtr Node::clone_node(Document* document, bool clone_children) copy = move(processing_instruction_copy); } // Otherwise, Do nothing. + else if (is(this)) { + copy = adopt_ref(*new DocumentFragment(*document)); + } // FIXME: 4. Set copy’s node document and document to copy, if copy is a document, and set copy’s node document to document otherwise.