Kaynağa Gözat

Fixed deep cloning options

In
https://github.com/select2/select2/commit/f1e86470ca08953d802489e6c0e0928674dc08cb
we tried to fix the issue where multiple instances created in a single
call would share the same options, and this worked for the most common
cases. Unfortunately it did not work for the case where data attributes
were also used with an options object, and as a result data attributes
would be copied to all instances. Data attributes are supposed to be
specific to a single instance.

This was fixed by moving the `true` for the deep copy to the start of
the `$.extend` call, as this is where jQuery looks for the deep copy
flag.

This closes https://github.com/select2/select2/issues/3485
Kevin Brown 9 yıl önce
ebeveyn
işleme
3c8366e876
1 değiştirilmiş dosya ile 1 ekleme ve 1 silme
  1. 1 1
      src/js/jquery.select2.js

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

@@ -17,7 +17,7 @@ define([
 
 
       if (typeof options === 'object') {
       if (typeof options === 'object') {
         this.each(function () {
         this.each(function () {
-          var instanceOptions = $.extend({}, options, true);
+          var instanceOptions = $.extend(true, {}, options);
 
 
           var instance = new Select2($(this), instanceOptions);
           var instance = new Select2($(this), instanceOptions);
         });
         });