b-fuze / deno-dom

Browser DOM & HTML parser in Deno
https://jsr.io/@b-fuze/deno-dom
MIT License
425 stars 47 forks source link

fix: `ChildNode` insert/replace methods don't work well with siblings #115

Closed andreubotella closed 2 years ago

andreubotella commented 2 years ago

The before, after and replaceWith methods of ChildNode instances don't behave well when its arguments contain sibling nodes or the node on which the method is called. This is because the index on which to insert the nodes in the parent is computed before nodesAndTextNodes is called, which removes the passed nodes from their parents, thus invalidating the index.

b-fuze commented 2 years ago

Thanks for this awesome PR! Sorry, it took me a while to get around to reviewing it, but just needs some small changes