From e219de092925f5258e36e738a8cfb27780523f8c Mon Sep 17 00:00:00 2001 From: Andrei Kashcha Date: Wed, 15 Mar 2017 06:58:20 -0700 Subject: [PATCH] Check for drop to prevent race conditions The `inHandler` uses `setTimeout()` function to schedule `this.open()` call. If client calls `drop.destroy()` before timeout is triggered, the instance of `this.drop` will be set to `null` which results in unhandled error in `open()` This change fixes the unhandled error. --- src/js/drop.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/js/drop.js b/src/js/drop.js index 92db0e0..e1a2d43 100644 --- a/src/js/drop.js +++ b/src/js/drop.js @@ -370,6 +370,11 @@ function createContext(options={}) { if (this.isOpened()) { return; } + + if (!this.drop) { + // The instance was destroyed + return; + } if (!this.drop.parentNode) { document.body.appendChild(this.drop);