LibWeb: Fix incorrect exception on replaceChild() with doctypes

We were checking for presence of the wrong child in the parent.
This commit is contained in:
Andreas Kling 2024-11-20 13:00:56 +01:00 committed by Andreas Kling
commit 4203b7823f
Notes: github-actions[bot] 2024-11-20 15:11:50 +00:00
4 changed files with 497 additions and 1 deletions

View file

@ -945,7 +945,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::replace_child(GC::Ref<Node> node, GC::R
} else if (is<DocumentType>(*node)) {
// DocumentType
// parent has a doctype child that is not child, or an element is preceding child.
if (first_child_of_type<DocumentType>() != node || child->has_preceding_node_of_type_in_tree_order<Element>())
if (first_child_of_type<DocumentType>() != child || child->has_preceding_node_of_type_in_tree_order<Element>())
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string);
}
}