LibHTML: DOM fixup should handle a completely empty document

We were forgetting to check if there was even a first child of the
root Document node.
This commit is contained in:
Andreas Kling 2019-10-19 21:20:42 +02:00
commit 73af2f8d02
Notes: sideshowbarker 2024-07-19 11:37:38 +09:00

View file

@ -57,7 +57,7 @@ bool Document::is_child_allowed(const Node& node) const
void Document::fixup()
{
if (!is<DocumentType>(first_child()))
if (!first_child() || !is<DocumentType>(*first_child()))
prepend_child(adopt(*new DocumentType(*this)));
if (is<HTMLHtmlElement>(first_child()->next_sibling()))