LibWeb: Fix node insertion in split_the_parent_of_nodes()

If we are to insert nodes _before_ the original parent, we need to
insert them at the original parent's index, not the index before that.
This commit is contained in:
Jelle Raaijmakers 2025-01-10 09:14:06 +01:00 committed by Andreas Kling
parent 83f48a07d4
commit 2987dd1060
Notes: github-actions[bot] 2025-01-10 22:38:53 +00:00

View file

@ -2512,7 +2512,7 @@ void split_the_parent_of_nodes(Vector<GC::Ref<DOM::Node>> const& node_list)
// 8. For each node in node list, insert node into the parent of original parent immediately
// before original parent, preserving ranges.
for (auto node : node_list)
move_node_preserving_ranges(node, parent_of_original_parent, original_parent_index - 1);
move_node_preserving_ranges(node, parent_of_original_parent, original_parent_index++);
// 9. If follows line break is true, and the first member of node list does not follow a line
// break, call createElement("br") on the context object and insert the result immediately