From 7ec1e753dc9493fe6f4f118658844106919144f3 Mon Sep 17 00:00:00 2001 From: Ronald J Kimball Date: Wed, 23 Jan 2013 13:53:15 -0500 Subject: [PATCH] Avoid error when label has no matching element $('#no_such_element').data("select2") returns null rather than undefined (jQuery 1.9.0). --- select2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/select2.js b/select2.js index 958d0f5d..0fa211e2 100644 --- a/select2.js +++ b/select2.js @@ -529,7 +529,7 @@ the specific language governing permissions and limitations under the Apache Lic attr = attr.replace(/([\[\].])/g,'\\$1'); /* escapes [, ], and . so properly selects the id */ target = $("#"+attr); target = target.data("select2"); - if (target !== undefined) { target.focus(); e.preventDefault();} + if (target !== undefined && target !== null) { target.focus(); e.preventDefault();} } }); });