mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:37:35 +00:00
LibWeb: Convert ChildNode to use TRY for error propagation
This commit is contained in:
parent
9ca10c9347
commit
ab0a354bb4
1 changed files with 7 additions and 28 deletions
|
@ -31,11 +31,7 @@ public:
|
|||
auto viable_previous_sibling = viable_previous_sibling_for_insertion(nodes);
|
||||
|
||||
// 4. 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, node->document());
|
||||
if (node_or_exception.is_exception())
|
||||
return node_or_exception.exception();
|
||||
|
||||
auto node_to_insert = node_or_exception.release_value();
|
||||
auto node_to_insert = TRY(convert_nodes_to_single_node(nodes, node->document()));
|
||||
|
||||
// 5. If viablePreviousSibling is null, then set it to parent’s first child; otherwise to viablePreviousSibling’s next sibling.
|
||||
if (!viable_previous_sibling)
|
||||
|
@ -44,9 +40,7 @@ public:
|
|||
viable_previous_sibling = viable_previous_sibling->next_sibling();
|
||||
|
||||
// 6. Pre-insert node into parent before viablePreviousSibling.
|
||||
auto result = parent->pre_insert(node_to_insert, viable_previous_sibling);
|
||||
if (result.is_exception())
|
||||
return result.exception();
|
||||
(void)TRY(parent->pre_insert(node_to_insert, viable_previous_sibling));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -67,16 +61,10 @@ public:
|
|||
auto viable_next_sibling = viable_nest_sibling_for_insertion(nodes);
|
||||
|
||||
// 4. 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, node->document());
|
||||
if (node_or_exception.is_exception())
|
||||
return node_or_exception.exception();
|
||||
|
||||
auto node_to_insert = node_or_exception.release_value();
|
||||
auto node_to_insert = TRY(convert_nodes_to_single_node(nodes, node->document()));
|
||||
|
||||
// 5. Pre-insert node into parent before viableNextSibling.
|
||||
auto result = parent->pre_insert(node_to_insert, viable_next_sibling);
|
||||
if (result.is_exception())
|
||||
return result.exception();
|
||||
(void)TRY(parent->pre_insert(node_to_insert, viable_next_sibling));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -97,26 +85,17 @@ public:
|
|||
auto viable_next_sibling = viable_nest_sibling_for_insertion(nodes);
|
||||
|
||||
// 4. 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, node->document());
|
||||
if (node_or_exception.is_exception())
|
||||
return node_or_exception.exception();
|
||||
|
||||
auto node_to_insert = node_or_exception.release_value();
|
||||
auto node_to_insert = TRY(convert_nodes_to_single_node(nodes, node->document()));
|
||||
|
||||
// 5. If this’s parent is parent, replace this with node within parent.
|
||||
// Note: This could have been inserted into node.
|
||||
if (node->parent() == parent) {
|
||||
auto result = parent->replace_child(node_to_insert, *node);
|
||||
if (result.is_exception())
|
||||
return result.exception();
|
||||
|
||||
(void)TRY(parent->replace_child(node_to_insert, *node));
|
||||
return {};
|
||||
}
|
||||
|
||||
// 6. Otherwise, pre-insert node into parent before viableNextSibling.
|
||||
auto result = parent->pre_insert(node_to_insert, viable_next_sibling);
|
||||
if (result.is_exception())
|
||||
return result.exception();
|
||||
(void)TRY(parent->pre_insert(node_to_insert, viable_next_sibling));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue