소스 검색

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.
Luke 4 년 전
부모
커밋
e4ae1cdd1f
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      Userland/Libraries/LibWeb/DOM/Node.cpp

+ 2 - 2
Userland/Libraries/LibWeb/DOM/Node.cpp

@@ -15,6 +15,7 @@
 #include <LibWeb/DOM/Comment.h>
 #include <LibWeb/DOM/DocumentType.h>
 #include <LibWeb/DOM/Element.h>
+#include <LibWeb/DOM/ElementFactory.h>
 #include <LibWeb/DOM/Event.h>
 #include <LibWeb/DOM/EventDispatcher.h>
 #include <LibWeb/DOM/EventListener.h>
@@ -412,8 +413,7 @@ NonnullRefPtr<Node> Node::clone_node(Document* document, bool clone_children) co
     RefPtr<Node> copy;
     if (is<Element>(this)) {
         auto& element = *verify_cast<Element>(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);
         });