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

Removing data after removed from DOM #3302

Closed
nblackburn opened this issue Jul 20, 2016 · 3 comments
Closed

Removing data after removed from DOM #3302

nblackburn opened this issue Jul 20, 2016 · 3 comments

Comments

@nblackburn
Copy link

nblackburn commented Jul 20, 2016

2016-07-20_23-11-13

I am currently implementing drag and drop functionality into a project of mine and have run into an issue where the library i am using removes the node from the DOM but upon syncing that action in the model, i am getting the following error...

Uncaught TypeError: Cannot read property 'removeChild' of null

This is because Vue is trying to remove a node that has already been removed by a third party plugin. I imagine it would be fixed by the inclusion of additional checks that the node exists which seems to be blocking the data from being removed.

Edit: I have added a gif mimicking the behavior of the third party library to showcase the error.

@yyx990803
Copy link
Member

Vue's update algorithm is built upon the assumption that the DOM structure is not to be altered by arbitrary 3rd party code. It's unlikely that the code could work even if a additional guard is added.

I have no intention to support this, but if you are willing to dig into the code and open a PR I'll review it.

@nblackburn
Copy link
Author

nblackburn commented Jul 20, 2016

@yyx990803 I am going to look into this further, in the mean time if you are aware of any better way of implementing such functionality in a more Vue friendly manner, i would appreciate it.

@nblackburn
Copy link
Author

nblackburn commented Jul 20, 2016

/**
 * Remove el from DOM
 *
 * @param {Element} el
 */

function remove(el) {

  if (!inDoc(el)) return false;

  el.parentNode.removeChild(el);
}

@yyx990803 Added a quick hack in to see if it was the cause of the issue and this seems to have resolved it, shall i create a PR?

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