Truly independent web browser
LibWeb: Recompute the tagName of an element moved to another document
Andreas Klingb01cf1a38286
diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cppindex f0b82a76826..0efc4b2bb35 100644--- a/Libraries/LibWeb/DOM/Element.cpp+++ b/Libraries/LibWeb/DOM/Element.cpp@@ -6977,6 +6977,10 @@ GC::Ptr<NamedNodeMap const> Element::attributes() constUtf16FlyString const& Element::html_uppercased_qualified_name() const{+ // NB: Whether the qualified name is uppercased depends on the node document, which can change when the element is+ // adopted. So we only use the cached uppercased name while it applies.+ if (namespace_uri() != Namespace::HTML || document().document_type() != Document::Type::HTML)+ return qualified_name();return ensure_element_rare_data().html_uppercased_qualified_name.ensure([&] { return make_html_uppercased_qualified_name(); });}diff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Element-tagName-adopt.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Element-tagName-adopt.txtindex d963be72816..cce8d0ff458 100644--- a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Element-tagName-adopt.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Element-tagName-adopt.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail tagName should not be uppercased when appended to XML document\ No newline at end of file+1 Pass+Pass tagName should not be uppercased when appended to XML document\ No newline at end of file