fiduswriter / simple-datatables

DataTables but in TypeScript transpiled to Vanilla JS
Other
1.3k stars 228 forks source link

[BUG] Destroying and removing the table element is not working correctly #379

Closed LuisFloresV closed 1 month ago

LuisFloresV commented 1 month ago

When destroying the data table instance and trying to remove the table element itself something is not working, this was working on version 9.0.0.

I have a project that uses that pattern of destroying the data table an then removing the element.

I created a jsfiddle to reproduce the error

Just click the destroy button and you will see that the data table is getting destroyed but the table itself is not being removed, this wasn't happening.

Probably related to the changes added to the destroy table commit SHA 01ef0d3573c952d826115507da6f7021590af58d

https://jsfiddle.net/LuisFV/ztcpx7k3/

johanneswilm commented 1 month ago

@LuisFloresV It recreates the HTML structure after the destruction which it previously didn't do correctly, which is why it was fixed in https://github.com/fiduswriter/simple-datatables/commit/01ef0d3573c952d826115507da6f7021590af58d . It is true that that then also means that event listeners and previous dom queries will not work correctly. I would not consider this in itself a bug and there is a simple way to avoid this issue by simply querying for the table after the destruction [1].

However, maybe there are other scenarios where that cannot be done or where that isn't enough? If you have such a scenario, let me know and I will reopen this issue.

[1] See https://jsfiddle.net/johanneswilm/z04pjrke/1/