1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

LibWeb: Implement "NodeIterator pre-removing steps"

These steps run when a node is about to be removed from its parent,
and adjust the position of any live NodeIterators so that they don't
point at a now-removed node.

Note that while this commit implements what's in the DOM specification,
the specification doesn't fully match what other browsers do.

Spec bug: https://github.com/whatwg/dom/issues/907
This commit is contained in:
Andreas Kling 2022-03-09 16:38:44 +01:00
parent acbdb95b0a
commit 9c6999ecf2
5 changed files with 91 additions and 2 deletions

View file

@ -387,7 +387,10 @@ void Node::remove(bool suppress_observers)
// FIXME: For each live range whose start node is parent and start offset is greater than index, decrease its start offset by 1.
// FIXME: For each live range whose end node is parent and end offset is greater than index, decrease its end offset by 1.
// FIXME: For each NodeIterator object iterator whose roots node document is nodes node document, run the NodeIterator pre-removing steps given node and iterator.
// For each NodeIterator object iterator whose roots node document is nodes node document, run the NodeIterator pre-removing steps given node and iterator.
document().for_each_node_iterator([&](NodeIterator& node_iterator) {
node_iterator.run_pre_removing_steps(*this);
});
// FIXME: Let oldPreviousSibling be nodes previous sibling. (Currently unused so not included)
// FIXME: Let oldNextSibling be nodes next sibling. (Currently unused so not included)