wnr / element-resize-detector

Optimized cross-browser resize listener for elements.
MIT License
1.32k stars 118 forks source link

Make scroll.js getters more defensive #85

Closed benkaiser closed 6 years ago

benkaiser commented 6 years ago

To avoid accessing invalid child nodes (when they may have been removed from the DOM by something else), continue to safely uninstall without throwing errors.

Linked to #61

wnr commented 6 years ago

Hi and thanks for the PR.

I'm not very fond of adding guards like that to code that should not be executed in the first place. The issue seems to be that some logic is executed (injectContainerElement) when it should not, due to the element being unmounted perhaps. The behaviour of the system is undefined in this case, and fixing the Exception throwing seems like the wrong solution to me. Instead, I would like to debug/analyze when exactly this issue happens so that we perhaps may find a way to prevent this line of execution.

If you would like to help with this, that would be awesome. Could you share a scenario when this happens? Perhaps a call-stack log?

Kind regards