Skip to content

Commit 7ec1e75

Browse files
committed
Avoid error when label has no matching element
$('#no_such_element').data("select2") returns null rather than undefined (jQuery 1.9.0).
1 parent 4e92c8b commit 7ec1e75

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

select2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ the specific language governing permissions and limitations under the Apache Lic
529529
attr = attr.replace(/([\[\].])/g,'\\$1'); /* escapes [, ], and . so properly selects the id */
530530
target = $("#"+attr);
531531
target = target.data("select2");
532-
if (target !== undefined) { target.focus(); e.preventDefault();}
532+
if (target !== undefined && target !== null) { target.focus(); e.preventDefault();}
533533
}
534534
});
535535
});

0 commit comments

Comments
 (0)