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

Bug: insertBefore doesn't remove the inserted node from the original parent node #107

Closed
henningko opened this issue Jun 16, 2022 · 2 comments

Comments

@henningko
Copy link

I am trying to unwrap a node (e.g. move all its content to the parent node), also see #106

The easiest implementation would be something like this, with el being any element that has a parent

let parent = el.parentNode;
while (el.firstChild) parent.insertBefore(el.firstChild, el);

Also see

However, with deno-dom, this puts me into an infinite loop, as el.firstChild never returns a falsy value. I assume this is due to the underlying childNodes not being updated.

@b-fuze
Copy link
Owner

b-fuze commented Jun 16, 2022

Which version of Deno DOM are you using? The .childNodes should definitely be live

@b-fuze
Copy link
Owner

b-fuze commented Jun 16, 2022

I was able to reproduce it, thanks for reporting it. I'll push a fix hopefully later today

@b-fuze b-fuze changed the title Bug: childNodes NodeList is not "live" Bug: insertBefore doesn't remove the inserted node from the original parent node Jun 16, 2022
@b-fuze b-fuze closed this as completed in e15f597 Jun 17, 2022
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

No branches or pull requests

2 participants