LibWeb: Make factory method of DOM::ElementFactory fallible

This commit is contained in:
Kenneth Myhra 2023-02-19 16:22:24 +01:00 committed by Andreas Kling
parent a2381a672d
commit ff92324fa5
Notes: sideshowbarker 2024-07-16 23:53:14 +09:00
15 changed files with 115 additions and 111 deletions

View file

@ -536,8 +536,8 @@ void HTMLParser::handle_before_html(HTMLToken& token)
// -> Anything else
AnythingElse:
// Create an html element whose node document is the Document object. Append it to the Document object. Put this element in the stack of open elements.
auto element = create_element(document(), HTML::TagNames::html, Namespace::HTML);
MUST(document().append_child(*element));
auto element = create_element(document(), HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(document().append_child(element));
m_stack_of_open_elements.push(element);
// Switch the insertion mode to "before head", then reprocess the token.
@ -638,7 +638,7 @@ JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& t
// 9. Let element be the result of creating an element given document, localName, given namespace, null, and is.
// FIXME: If will execute script is true, set the synchronous custom elements flag; otherwise, leave it unset.
// FIXME: Pass in `null` and `is`.
auto element = create_element(*document, local_name, namespace_);
auto element = create_element(*document, local_name, namespace_).release_value_but_fixme_should_propagate_errors();
// 10. Append each attribute in the given token to element.
// FIXME: This isn't the exact `append` the spec is talking about.
@ -3499,7 +3499,7 @@ Vector<JS::Handle<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& cont
}
// 5. Let root be a new html element with no attributes.
auto root = create_element(context_element.document(), HTML::TagNames::html, Namespace::HTML);
auto root = create_element(context_element.document(), HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
// 6. Append the element root to the Document node created above.
MUST(temp_document->append_child(root));