diff --git a/Tests/LibWeb/Text/expected/DOM/CDATASection-cloneNode.txt b/Tests/LibWeb/Text/expected/DOM/CDATASection-cloneNode.txt new file mode 100644 index 00000000000..cb435e9906d --- /dev/null +++ b/Tests/LibWeb/Text/expected/DOM/CDATASection-cloneNode.txt @@ -0,0 +1 @@ +Cloned CDATASection node data: PASS \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/DOM/CDATASection-cloneNode.html b/Tests/LibWeb/Text/input/DOM/CDATASection-cloneNode.html new file mode 100644 index 00000000000..9fe11bbd24f --- /dev/null +++ b/Tests/LibWeb/Text/input/DOM/CDATASection-cloneNode.html @@ -0,0 +1,9 @@ + + diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 764432dd1d1..7c23bca5d8f 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -978,12 +978,14 @@ WebIDL::ExceptionOr> Node::clone_node(Document* document, // Set copy’s namespace, namespace prefix, local name, and value to those of node. auto& attr = static_cast(*this); copy = attr.clone(*document); - } else if (is(this)) { + } + // NOTE: is() currently returns true only for text nodes, not for descendant types of Text. + else if (is(this) || is(this)) { // Text - auto text = verify_cast(this); + auto& text = static_cast(*this); // Set copy’s data to that of node. - auto text_copy = heap().allocate(realm(), *document, text->data()); + auto text_copy = heap().allocate(realm(), *document, text.data()); copy = move(text_copy); } else if (is(this)) { // Comment