JonathanDn / vue-dropdown

A highly dynamic vue dropdown component
39 stars 12 forks source link

Event listener never removed leads to memory leak #14

Open felicien-brochu opened 4 years ago

felicien-brochu commented 4 years ago

The "resize" listener added on window here: https://github.com/JonathanDn/vue-dropdown/blob/03ba5754c370fa257277fb7ca1d7ce6250a4f179/dropdown.vue#L96 is never removed. It leads to memory leak. Also I think you should not use a directive here. Because you cannot retain a reference to the closure calcHeight() in the directive, so you won't be able to remove the listener afterwards.

MitchellBouwman commented 4 years ago

That's not true, in the destroyed() hook is a removeEventListener.

JonathanDn commented 4 years ago

Hey @felicien-brochu those are 2 separate issues please open a new issues for the directive issue and lets discuss there.

About the event listener, feel free to open a PR with the fix to remove that listener.