laurenashpole / vue-inner-image-zoom

https://laurenashpole.github.io/vue-inner-image-zoom
141 stars 16 forks source link

Removed DOM element #53

Open madiyetov opened 2 years ago

madiyetov commented 2 years ago

We don't remove the handleLoad listener from img when component is destroyed. In case of slow internet connection, image might be loaded after this component was destroyed (for example, inside dialog or modal). As a result we can have the next error:

TypeError: Cannot read properties of undefined (reading 'getBoundingClientRect')
   ./node_modules/vue-inner-image-zoom/lib/vue-inner-image-zoom.umd.js at line 2855
   ./node_modules/vue-inner-image-zoom/lib/vue-inner-image-zoom.umd.js at line 2724

As a fix, we should remove the event listener or add check for this.$refs.img here: https://github.com/laurenashpole/vue-inner-image-zoom/blob/master/src/InnerImageZoom/InnerImageZoom.vue#L266

laurenashpole commented 2 years ago

Thanks for flagging this! I'll add a fix in the next update.