Skip to content

Commit ab1a8b9

Browse files
committed
some code cleanup. fixes select2#269
1 parent 00058ab commit ab1a8b9

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

select2.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
nextUid=(function() { var counter=1; return function() { return counter++; }; }());
9494

9595
function escapeMarkup(markup) {
96-
if (typeof(markup) === "string") {
96+
if (markup && typeof(markup) === "string") {
9797
return markup.replace("&", "&");
9898
} else {
9999
return markup;
@@ -393,7 +393,7 @@
393393
*/
394394
$(document).ready(function () {
395395
$(document).delegate("*", "mousedown touchend", function (e) {
396-
var target = $(e.target).closest("div.select2-container").get(0);
396+
var target = $(e.target).closest("div.select2-container").get(0), attr;
397397
if (target) {
398398
$(document).find("div.select2-container-active").each(function () {
399399
if (this !== target) $(this).data("select2").blur();
@@ -406,8 +406,9 @@
406406
}
407407

408408
target=$(e.target);
409-
if ("LABEL" === e.target.tagName && target.attr("for").length > 0) {
410-
target = $("#"+target.attr("for"));
409+
attr = target.attr("for");
410+
if ("LABEL" === e.target.tagName && attr && attr.length > 0) {
411+
target = $("#"+attr);
411412
target = target.data("select2");
412413
if (target !== undefined) { target.focus(); e.preventDefault();}
413414
}

0 commit comments

Comments
 (0)