wakirin / Litepicker

Date range picker - lightweight, no dependencies
MIT License
898 stars 132 forks source link

Destroy method should wipe out entire Litepicker object? #289

Open bewards opened 2 years ago

bewards commented 2 years ago

Using the Litepicker within a Svelte project, I have the Litepicker element nested within a modal that is bound to a "selected product". When a "selected product" object is not selected, the modal disappears and is wiped from the DOM. Once a "selected product" is activated and the modal re-appears, the Litepicker no longer opens. I am able to fix this by destroying the Litepicker and adding a null check condition to re-initialize it, but I also have to set the litepicker object to null because the destroy method only wipes out the protected member ui. Since I don't have access to this ui property in TypeScript, I have to manually set my instance of Litepicker to null as well for that check to work and for it to re-initialize. Out of curiosity, is there a reason the destroy method doesn't wipe out the entire instance?

This is a low hanging fruit question and not so much a bug, but I was expecting the destroy method to wipe out the instance so that garbage collection does it's thing and the litepicker instance is no longer defined.