HubSpot/drop

Events bound to document

Closed this issue · 2 comments

For every drop instance, there is an event bound to the document for handling close. I have a single page application so the bound events to the document are never removed and after a while, there will be thousands of events bound to the document.

Good catch. It seems like we could just add the removeEventListener on the Drop#destroy method here. Would you like to see if that works and open a pull request if it does?

Sorry for the last response. On second thought remove works as expected as the purpose is to remove the instance from the DOM, but not entirely. For that, you can use destroy which will remove the drop and all of the events attached to it. The events bound to document actually get cleaned up as well here. Let me know if it's still an issue though and I'll be happy to take another look.