mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +00:00
LibWeb: Implement replacing the current body when setting document.body
Also adds an exception check to the append at the end.
This commit is contained in:
parent
b6004a4ce1
commit
df52040ce9
1 changed files with 6 additions and 2 deletions
|
@ -222,7 +222,9 @@ ExceptionOr<void> Document::set_body(HTML::HTMLElement& new_body)
|
||||||
|
|
||||||
auto* existing_body = body();
|
auto* existing_body = body();
|
||||||
if (existing_body) {
|
if (existing_body) {
|
||||||
TODO();
|
auto replace_result = existing_body->parent()->replace_child(new_body, *existing_body);
|
||||||
|
if (replace_result.is_exception())
|
||||||
|
return NonnullRefPtr<DOMException>(replace_result.exception());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +232,9 @@ ExceptionOr<void> Document::set_body(HTML::HTMLElement& new_body)
|
||||||
if (!document_element)
|
if (!document_element)
|
||||||
return DOM::HierarchyRequestError::create("Missing document element");
|
return DOM::HierarchyRequestError::create("Missing document element");
|
||||||
|
|
||||||
document_element->append_child(new_body);
|
auto append_result = document_element->append_child(new_body);
|
||||||
|
if (append_result.is_exception())
|
||||||
|
return NonnullRefPtr<DOMException>(append_result.exception());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue