Преглед изворни кода

Fix calling select2('', args) on multiple elements

This fixes an issue that has existed since Select2 4.0.1 where the
arguments passed into each `<select>` were mutated. This no longer
mutates the arguments for each element, and instead only drops the
first argument once.

This closes https://github.com/select2/select2/issues/4245
Kevin Brown пре 9 година
родитељ
комит
c2c1aeef31
1 измењених фајлова са 1 додато и 2 уклоњено
  1. 1 2
      src/js/jquery.select2.js

+ 1 - 2
src/js/jquery.select2.js

@@ -22,6 +22,7 @@ define([
         return this;
       } else if (typeof options === 'string') {
         var ret;
+        var args = Array.prototype.slice.call(arguments, 1);
 
         this.each(function () {
           var instance = $(this).data('select2');
@@ -33,8 +34,6 @@ define([
             );
           }
 
-          var args = Array.prototype.slice.call(arguments, 1);
-
           ret = instance[options].apply(instance, args);
         });