LibWeb: Check parent node exists before checking its type

This commit is contained in:
Tim Ledbetter 2025-07-15 06:18:31 +01:00 committed by Shannon Booth
commit d1678e03ff
Notes: github-actions[bot] 2025-07-15 06:39:00 +00:00
2 changed files with 8 additions and 1 deletions

View file

@ -232,7 +232,7 @@ void XMLDocumentBuilder::element_end(const XML::Name& name)
};
auto* parent = m_current_node->parent_node();
if (parent->is_document_fragment()) {
if (parent && parent->is_document_fragment()) {
auto template_parent_node = m_template_node_stack.take_last();
parent = template_parent_node.ptr();
}

View file

@ -0,0 +1,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script>
var newRoot = document.createElementNS("http://www.w3.org/2000/svg", "test");
document.removeChild(document.documentElement);
document.appendChild(newRoot);
</script></head>
</html>