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

Error removing tr when data array is altered #3

Closed
dejan9393 opened this issue Sep 17, 2019 · 3 comments
Closed

Error removing tr when data array is altered #3

dejan9393 opened this issue Sep 17, 2019 · 3 comments

Comments

@dejan9393
Copy link
Contributor

Receiving an "Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node." when changing the data array, only under certain conditions which I haven't dug deep enough to figure out.

I have managed to make a specific reproduction to showcase the issue by initially having a data array with 10 elements, updating it to an array of 6 elements, then again down to 4 elements:

demo here:
https://infrequent-air.glitch.me/

@RoXuS
Copy link
Contributor

RoXuS commented Sep 17, 2019

Hi @dejan9393, thanks for the issue.
We use the component with a footer to change page and size of our data and we don't have this issue, I have to investigate before merging your PR.

Thx !

@dejan9393
Copy link
Contributor Author

Yep i'm also using the included footer for changing page/size of the data and most of the time it works fine - it's only with certain changes in the size of the data that it actually happens.

I think it's because the array is re-indexed when it is spliced, so the next iteration removes a TR node but then removes no row from the tables array.

Example:

Let's say table is an array of 4 rows:

this.table = [a, b, c, d]

We change the size of our data to 2, leaving only two rows, splicing indexes 3 & 4 from table:

this.table.splice(2, 1) (table gets re-indexed and is now [0 => a, 1 => b, 2 => d])

this.table.splice(3, 1) (table remains the same, as there is nothing at index 3)

Next time the data changes and we attempt to remove the tr at index 2, we get an error as that tr had previously been removed, but not correctly removed from the tables array

@RoXuS
Copy link
Contributor

RoXuS commented Sep 19, 2019

great, its fixed by your PR thx !

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