mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
LibWeb: Convert InnerHTML to use TRY for error propagation
This commit is contained in:
parent
3cb7c463a7
commit
07a2c58da0
1 changed files with 2 additions and 7 deletions
|
@ -21,9 +21,7 @@ static DOM::ExceptionOr<NonnullRefPtr<DOM::DocumentFragment>> parse_fragment(Str
|
||||||
|
|
||||||
for (auto& child : new_children) {
|
for (auto& child : new_children) {
|
||||||
// I don't know if this can throw here, but let's be safe.
|
// I don't know if this can throw here, but let's be safe.
|
||||||
auto result = fragment->append_child(child);
|
(void)TRY(fragment->append_child(child));
|
||||||
if (result.is_exception())
|
|
||||||
return result.exception();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fragment;
|
return fragment;
|
||||||
|
@ -37,10 +35,7 @@ DOM::ExceptionOr<void> inner_html_setter(NonnullRefPtr<DOM::Node> context_object
|
||||||
NonnullRefPtr<DOM::Element> context_element = is<DOM::ShadowRoot>(*context_object) ? *verify_cast<DOM::ShadowRoot>(*context_object).host() : verify_cast<DOM::Element>(*context_object);
|
NonnullRefPtr<DOM::Element> context_element = is<DOM::ShadowRoot>(*context_object) ? *verify_cast<DOM::ShadowRoot>(*context_object).host() : verify_cast<DOM::Element>(*context_object);
|
||||||
|
|
||||||
// 2. Let fragment be the result of invoking the fragment parsing algorithm with the new value as markup, and with context element.
|
// 2. Let fragment be the result of invoking the fragment parsing algorithm with the new value as markup, and with context element.
|
||||||
auto fragment_or_exception = parse_fragment(value, context_element);
|
auto fragment = TRY(parse_fragment(value, context_element));
|
||||||
if (fragment_or_exception.is_exception())
|
|
||||||
return fragment_or_exception.exception();
|
|
||||||
auto fragment = fragment_or_exception.release_value();
|
|
||||||
|
|
||||||
// 3. If the context object is a template element, then let context object be the template's template contents (a DocumentFragment).
|
// 3. If the context object is a template element, then let context object be the template's template contents (a DocumentFragment).
|
||||||
if (is<HTML::HTMLTemplateElement>(*context_object))
|
if (is<HTML::HTMLTemplateElement>(*context_object))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue