From 1de4be3749528e71c53438673092f59abbbf1f71 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Fri, 31 Oct 2014 18:15:32 -0400 Subject: [PATCH] Fixed TypeError when destroying Select2 This fixes #2587. --- select2.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index 5fc599aa..5591ea9d 100644 --- a/select2.js +++ b/select2.js @@ -2214,11 +2214,17 @@ the specific language governing permissions and limitations under the Apache Lic })); selection.on("mousedown touchstart", "abbr", this.bind(function (e) { - if (!this.isInterfaceEnabled()) return; + if (!this.isInterfaceEnabled()) { + return; + } + this.clear(); killEventImmediately(e); this.close(); - this.selection.focus(); + + if (this.selection) { + this.selection.focus(); + } })); selection.on("mousedown touchstart", this.bind(function (e) {