LibWeb: Make HTML fragment parsing return ExceptionOr

Update Element::parse_fragment and Node::unsafely_set_html to
propagate exceptions.

This refactor is needed as a prerequisite for implementing the XML
fragment parser, which requires consistent error handling in fragment
parsing.
This commit is contained in:
mikiubo 2025-09-10 23:06:59 +02:00 committed by Sam Atkins
parent 8417d74328
commit 0b715b20a2
Notes: github-actions[bot] 2025-10-23 10:08:11 +00:00
4 changed files with 5 additions and 4 deletions

View file

@ -5009,7 +5009,7 @@ DOM::Document& HTMLParser::document()
}
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
Vector<GC::Root<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& context_element, StringView markup, AllowDeclarativeShadowRoots allow_declarative_shadow_roots)
WebIDL::ExceptionOr<Vector<GC::Root<DOM::Node>>> HTMLParser::parse_html_fragment(DOM::Element& context_element, StringView markup, AllowDeclarativeShadowRoots allow_declarative_shadow_roots)
{
// 1. Let document be a Document node whose type is "html".
auto temp_document = DOM::Document::create_for_fragment_parsing(context_element.realm());

View file

@ -75,7 +75,8 @@ public:
No,
Yes,
};
static Vector<GC::Root<DOM::Node>> parse_html_fragment(DOM::Element& context_element, StringView, AllowDeclarativeShadowRoots = AllowDeclarativeShadowRoots::No);
static WebIDL::ExceptionOr<Vector<GC::Root<DOM::Node>>> parse_html_fragment(DOM::Element& context_element, StringView, AllowDeclarativeShadowRoots = AllowDeclarativeShadowRoots::No);
enum class SerializableShadowRoots {
No,
Yes,