Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [1406] Fixes issue with insertBefore and comment reference node #1407

Conversation

mdafanasev
Copy link
Contributor

Resolves #1406.

I found that when the reference node is not an Element, such as a comment, the insertion correctly occurs in the childNodes array, but the target node is not removed from childNodes; it is only removed from children. Therefore, I have added code that also removes the target node from childNodes.

Copy link
Owner

@capricorn86 capricorn86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @mdafanasev! 🌟

In case you are interested, i'm working on a fix that removes ElementUtility and refactors the code to simplify the logic to avoid these kind of bugs 🙂
https://github.com/capricorn86/happy-dom/pull/1359/files#diff-f84cace34f3e54afcf796c8ae3f1f853f7abeb0451a8d52e2213db8857ae58dcR127

@capricorn86 capricorn86 merged commit d159d4d into capricorn86:master May 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

insertBefore with a comment node causes duplication of node
2 participants