From e4ae1cdd1f4734a8cb33106d88bc4458e3c46ea9 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 5 Jul 2021 05:28:29 +0100 Subject: [PATCH] LibWeb: Use the element factory in clone_node It was directly creating a new Element object instead of creating the appropriate element. For example, document.body.cloneNode(true) would return an Element instead of an HTMLBodyElement. --- Userland/Libraries/LibWeb/DOM/Node.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index c90dcadf98..d2f70f3d72 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -412,8 +413,7 @@ NonnullRefPtr Node::clone_node(Document* document, bool clone_children) co RefPtr copy; if (is(this)) { auto& element = *verify_cast(this); - auto qualified_name = QualifiedName(element.local_name(), element.prefix(), element.namespace_()); - auto element_copy = adopt_ref(*new Element(*document, move(qualified_name))); + auto element_copy = DOM::create_element(*document, element.local_name(), element.namespace_() /* FIXME: node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset */); element.for_each_attribute([&](auto& name, auto& value) { element_copy->set_attribute(name, value); });