summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-03-22 12:39:49 +0000
committerLinus Groh <mail@linusgroh.de>2022-03-22 18:05:25 +0000
commita68d31debd103695c9d97e8db5b8a317d185ed35 (patch)
treeb2f5e3d07d461e3e3c7aff23a25ca90b06f57b3e /Userland/Libraries/LibWeb
parent8d20fb1e9487f9ec978560ba8ec0dfbbbab30a88 (diff)
downloadserenity-a68d31debd103695c9d97e8db5b8a317d185ed35.zip
LibWeb: Convert ParentNode to use TRY for error propagation
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/DOM/ParentNode.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp
index dde6fc9b43..2734295f91 100644
--- a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp
+++ b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp
@@ -160,16 +160,10 @@ NonnullRefPtr<HTMLCollection> ParentNode::get_elements_by_tag_name_ns(FlyString
ExceptionOr<void> ParentNode::prepend(Vector<Variant<NonnullRefPtr<Node>, String>> const& nodes)
{
// 1. Let node be the result of converting nodes into a node given nodes and this’s node document.
- auto node_or_exception = convert_nodes_to_single_node(nodes, document());
- if (node_or_exception.is_exception())
- return node_or_exception.exception();
-
- auto node = node_or_exception.release_value();
+ auto node = TRY(convert_nodes_to_single_node(nodes, document()));
// 2. Pre-insert node into this before this’s first child.
- auto result = pre_insert(node, first_child());
- if (result.is_exception())
- return result.exception();
+ (void)TRY(pre_insert(node, first_child()));
return {};
}
@@ -177,16 +171,10 @@ ExceptionOr<void> ParentNode::prepend(Vector<Variant<NonnullRefPtr<Node>, String
ExceptionOr<void> ParentNode::append(Vector<Variant<NonnullRefPtr<Node>, String>> const& nodes)
{
// 1. Let node be the result of converting nodes into a node given nodes and this’s node document.
- auto node_or_exception = convert_nodes_to_single_node(nodes, document());
- if (node_or_exception.is_exception())
- return node_or_exception.exception();
-
- auto node = node_or_exception.release_value();
+ auto node = TRY(convert_nodes_to_single_node(nodes, document()));
// 2. Append node to this.
- auto result = append_child(node);
- if (result.is_exception())
- return result.exception();
+ (void)TRY(append_child(node));
return {};
}
@@ -194,16 +182,10 @@ ExceptionOr<void> ParentNode::append(Vector<Variant<NonnullRefPtr<Node>, String>
ExceptionOr<void> ParentNode::replace_children(Vector<Variant<NonnullRefPtr<Node>, String>> const& nodes)
{
// 1. Let node be the result of converting nodes into a node given nodes and this’s node document.
- auto node_or_exception = convert_nodes_to_single_node(nodes, document());
- if (node_or_exception.is_exception())
- return node_or_exception.exception();
-
- auto node = node_or_exception.release_value();
+ auto node = TRY(convert_nodes_to_single_node(nodes, document()));
// 2. Ensure pre-insertion validity of node into this before null.
- auto validity_exception = ensure_pre_insertion_validity(node, nullptr);
- if (validity_exception.is_exception())
- return validity_exception.exception();
+ TRY(ensure_pre_insertion_validity(node, nullptr));
// 3. Replace all with node within this.
replace_all(node);