Parcourir la source

Merge pull request #186 from nutshellcrm/focus-syntax-error-1.6

Fixes syntax error in jQuery < 1.6 (":focus" selector is unavailable)
Igor Vaynberg il y a 13 ans
Parent
commit
f272ac9f80
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. 3 2
      select2.js

+ 3 - 2
select2.js

@@ -980,7 +980,8 @@
             this.close();
             this.container.removeClass("select2-container-active");
             this.dropdown.removeClass("select2-drop-active");
-            if (this.search.is(":focus")) { this.search.blur(); }
+            // synonymous to .is(':focus'), which is available in jquery >= 1.6
+            if (this.search[0] === document.activeElement) { this.search.blur(); }
             this.clearSearch();
             this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
         },
@@ -1082,7 +1083,7 @@
 
         // single
         isFocused: function () {
-            return this.selection.is(":focus");
+            return this.selection[0] === document.activeElement;
         },
 
         // single