angular-sortable-view
angular-sortable-view copied to clipboard
Remove svElement event listeners on $destroy
trafficstars
This fixes a Cannot read property 'forEach' of undefined throw that happens if one of the sortable elements has a child with a mouseup event handler that calls Event.stopPropagation(). In that case, the svElement mousedown/touchstart event handler fires, registering the mousemove/touchmove event handler on the documentElement, but there's no mouseup because it was stopped from propagating. This event handler keeps being registered even if the component doesn't exist anymore.
The fix involves de-registering the mousemove/touchmove event handler on the svElement's $destroy event, and it's pretty low-risk.