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

"node.parentNode is null" thrown when removing from nested, keyed list #2682

Closed
amccausl opened this issue May 5, 2019 · 4 comments
Closed

Comments

@amccausl
Copy link

amccausl commented May 5, 2019

REPL link

When removing item from nested, keyed list: console error is thrown

To reproduce:

  • click button to remove a cat
  • internal detach method called twice for the list item (second call tries to access null parentNode, throwing exception)

Happened on 3.1 & 3.2. Fixed if top level each or nested component is removed. Seems similar to #2668

@beenotung
Copy link

maybe related #2666

@MikeMatrix
Copy link
Contributor

So after long time debugging, I think the issue appears to be that, the <li> element get's an outro handler attached by outro_and_destroy_block, which is attached, because we have a component inside it, which potentially could have an outro attached.

Then the inner each loop runs our outro handler in outros.callbacks through check_outros, which then runs our detach down the line.
Afterwards the handler is not removed.
The outer loop gets to it's update routine and will down the line run check_outros again, which runs our handler we attached earlier again, which obviously tries to detach an already detached element. -> NPE

Easy fix, that'll make sure we never try to detach an element with no parent. -> check parentNode and only if it's not null attempt to detach node from it's parentNode.
This however doesn't fix the underlying issue of the handler being called twice. Or the fact that it thinks it has to run an outro, because it has a component underneath, even if that components o outro handler is noop.

This should help kick start removing this issue.

I think we should probably null check parentNode anyways...

@Conduitry
Copy link
Member

This appears to have been fixed ... at some point ... by one of the outro/detach fixes.

@amccausl
Copy link
Author

Thanks for the resolution :)

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

4 participants