From 3f14f773f967b484bf698c32a24041121fe99234 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Wed, 30 Jan 2013 22:38:58 -0800 Subject: [PATCH] dont error out when 'x' is removed really fast multiple times. fixes #745 --- select2.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/select2.js b/select2.js index 769fd8e5..b4f6d2cc 100644 --- a/select2.js +++ b/select2.js @@ -2169,6 +2169,12 @@ the specific language governing permissions and limitations under the Apache Lic data = selected.data("select2-data"); + if (!data) { + // prevent a race condition when the 'x' is clicked really fast repeatedly the event can be queued + // and invoked on an element already removed + return; + } + index = indexOf(this.id(data), val); if (index >= 0) {