Browse Source

workaround for IE when manipulating classes. fixes #937 fixes #1017

Igor Vaynberg 12 years ago
parent
commit
ae4b24a7e8
1 changed files with 5 additions and 3 deletions
  1. 5 3
      select2.js

+ 5 - 3
select2.js

@@ -284,7 +284,8 @@ the specific language governing permissions and limitations under the Apache Lic
         var classes, replacements = [], adapted;
         var classes, replacements = [], adapted;
 
 
         classes = dest.attr("class");
         classes = dest.attr("class");
-        if (typeof classes === "string") {
+        if (classes) {
+            classes = '' + classes; // for IE which returns object
             $(classes.split(" ")).each2(function() {
             $(classes.split(" ")).each2(function() {
                 if (this.indexOf("select2-") === 0) {
                 if (this.indexOf("select2-") === 0) {
                     replacements.push(this);
                     replacements.push(this);
@@ -292,11 +293,12 @@ the specific language governing permissions and limitations under the Apache Lic
             });
             });
         }
         }
         classes = src.attr("class");
         classes = src.attr("class");
-        if (typeof classes === "string") {
+        if (classes) {
+            classes = '' + classes; // for IE which returns object
             $(classes.split(" ")).each2(function() {
             $(classes.split(" ")).each2(function() {
                 if (this.indexOf("select2-") !== 0) {
                 if (this.indexOf("select2-") !== 0) {
                     adapted = adapter(this);
                     adapted = adapter(this);
-                    if (typeof adapted === "string" && adapted.length > 0) {
+                    if (adapted) {
                         replacements.push(this);
                         replacements.push(this);
                     }
                     }
                 }
                 }