Current implementation of replaceWith is missing setting _nextNode and _previousNode for siblings of the node argument (the one that replaces current node).
It is causing tree structure issues and bugs when replaceWith is called with an argument that is already in the same document tree (added test for it).
Cant find this documented but Dart and JS DOM versions of this method are simply moving the replacing element from the current location so guess this should work same way.
Refactored a little bit to avoid logic repetition.
Current implementation of
replaceWith
is missing setting_nextNode
and_previousNode
for siblings of the node argument (the one that replaces current node).It is causing tree structure issues and bugs when
replaceWith
is called with an argument that is already in the same document tree (added test for it).Cant find this documented but Dart and JS DOM versions of this method are simply moving the replacing element from the current location so guess this should work same way.
Refactored a little bit to avoid logic repetition.