Skip to content

Commit

Permalink
fix: ie fix for event bindings on unmounted components (#1338)
Browse files Browse the repository at this point in the history
* IE fix for event bindings on unmounted components.

* Fix Unable to get property x of undefined or null reference
  • Loading branch information
dkniffin authored and jquense committed May 24, 2019
1 parent 9689b7d commit 8ef00d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const clickInterval = 250

class Selection {
constructor(node, { global = false, longPressThreshold = 250 } = {}) {
this.isDetached = false
this.container = node
this.globalMouse = !node || global
this.longPressThreshold = longPressThreshold
Expand Down Expand Up @@ -95,6 +96,7 @@ class Selection {
}

teardown() {
this.isDetached = true
this.listeners = Object.create(null)
this._onTouchMoveWindowListener && this._onTouchMoveWindowListener.remove()
this._onInitialEventListener && this._onInitialEventListener.remove()
Expand Down Expand Up @@ -206,6 +208,10 @@ class Selection {
}

_handleInitialEvent(e) {
if (this.isDetached) {
return
}

const { clientX, clientY, pageX, pageY } = getEventCoordinates(e)
let node = this.container(),
collides,
Expand Down Expand Up @@ -344,7 +350,7 @@ class Selection {
}

_handleMoveEvent(e) {
if (this._initialEventData === null) {
if (this._initialEventData === null || this.isDetached) {
return
}

Expand Down

0 comments on commit 8ef00d6

Please sign in to comment.