mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
LibWeb: Support assigning to document.body when it is null
This commit is contained in:
parent
9100a1fde9
commit
b126ead34e
2 changed files with 10 additions and 5 deletions
|
@ -183,6 +183,11 @@ bool Document::is_child_allowed(const Node& node) const
|
|||
}
|
||||
}
|
||||
|
||||
Element* Document::document_element()
|
||||
{
|
||||
return first_child_of_type<Element>();
|
||||
}
|
||||
|
||||
const Element* Document::document_element() const
|
||||
{
|
||||
return first_child_of_type<Element>();
|
||||
|
@ -230,13 +235,11 @@ ExceptionOr<void> Document::set_body(HTML::HTMLElement& new_body)
|
|||
return {};
|
||||
}
|
||||
|
||||
auto* html = document_element();
|
||||
if (!html)
|
||||
auto* document_element = this->document_element();
|
||||
if (!document_element)
|
||||
return DOM::HierarchyRequestError::create("Missing document element");
|
||||
|
||||
// FIXME: Implement this once there's a non-const first_child_of_type:
|
||||
// "Otherwise, the body element is null, but there's a document element. Append the new value to the document element."
|
||||
TODO();
|
||||
document_element->append_child(new_body);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue