mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:02:43 +00:00 
			
		
		
		
	LibWeb: Convert ParentNode to use TRY for error propagation
This commit is contained in:
		
							parent
							
								
									8d20fb1e94
								
							
						
					
					
						commit
						a68d31debd
					
				
					 1 changed files with 6 additions and 24 deletions
				
			
		|  | @ -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) | 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.
 |     // 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()); |     auto node = TRY(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(); |  | ||||||
| 
 | 
 | ||||||
|     // 2. Pre-insert node into this before this’s first child.
 |     // 2. Pre-insert node into this before this’s first child.
 | ||||||
|     auto result = pre_insert(node, first_child()); |     (void)TRY(pre_insert(node, first_child())); | ||||||
|     if (result.is_exception()) |  | ||||||
|         return result.exception(); |  | ||||||
| 
 | 
 | ||||||
|     return {}; |     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) | 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.
 |     // 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()); |     auto node = TRY(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(); |  | ||||||
| 
 | 
 | ||||||
|     // 2. Append node to this.
 |     // 2. Append node to this.
 | ||||||
|     auto result = append_child(node); |     (void)TRY(append_child(node)); | ||||||
|     if (result.is_exception()) |  | ||||||
|         return result.exception(); |  | ||||||
| 
 | 
 | ||||||
|     return {}; |     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) | 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.
 |     // 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()); |     auto node = TRY(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(); |  | ||||||
| 
 | 
 | ||||||
|     // 2. Ensure pre-insertion validity of node into this before null.
 |     // 2. Ensure pre-insertion validity of node into this before null.
 | ||||||
|     auto validity_exception = ensure_pre_insertion_validity(node, nullptr); |     TRY(ensure_pre_insertion_validity(node, nullptr)); | ||||||
|     if (validity_exception.is_exception()) |  | ||||||
|         return validity_exception.exception(); |  | ||||||
| 
 | 
 | ||||||
|     // 3. Replace all with node within this.
 |     // 3. Replace all with node within this.
 | ||||||
|     replace_all(node); |     replace_all(node); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh