mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibWeb: Fix nodesToRemove collecting traversal in Range::delete_contents
With this change children are no longer skipped in tree traversal when start node of range equals to end node of range. Fixes https://github.com/SerenityOS/serenity/issues/24036
This commit is contained in:
parent
cedf6dd2c3
commit
9540af6489
Notes:
sideshowbarker
2024-07-17 18:38:54 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/9540af6489 Pull-request: https://github.com/SerenityOS/serenity/pull/24038 Issue: https://github.com/SerenityOS/serenity/issues/24036
1
Tests/LibWeb/Text/expected/DOM/Range-deleteContents.txt
Normal file
1
Tests/LibWeb/Text/expected/DOM/Range-deleteContents.txt
Normal file
@ -0,0 +1 @@
|
||||
before after
|
17
Tests/LibWeb/Text/input/DOM/Range-deleteContents.html
Normal file
17
Tests/LibWeb/Text/input/DOM/Range-deleteContents.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
before
|
||||
<div id="for-deletion">
|
||||
<div>should</div>
|
||||
<div>be</div>
|
||||
<div>gone</div>
|
||||
</div>
|
||||
after
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const element = document.getElementById("for-deletion");
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(element);
|
||||
range.deleteContents();
|
||||
});
|
||||
</script>
|
@ -1118,7 +1118,7 @@ WebIDL::ExceptionOr<void> Range::delete_contents()
|
||||
|
||||
// 4. Let nodes to remove be a list of all the nodes that are contained in this, in tree order, omitting any node whose parent is also contained in this.
|
||||
JS::MarkedVector<Node*> nodes_to_remove(heap());
|
||||
for (Node const* node = start_container(); node != end_container()->next_in_pre_order(); node = node->next_in_pre_order()) {
|
||||
for (Node const* node = start_container(); node != end_container()->next_sibling(); node = node->next_in_pre_order()) {
|
||||
if (contains_node(*node) && (!node->parent_node() || !contains_node(*node->parent_node())))
|
||||
nodes_to_remove.append(const_cast<Node*>(node));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user