소스 검색

Clone the options for group elements

This will always clone the options that are passed in when
initializing Select2 on multiple objects (like `$("select")`) so
it doesn't always assume that the configuration is the exact same.
This prevents any reference-based tricks for modifying the data
within Select2, but some would look at that as an upside.
Kevin Brown 10 년 전
부모
커밋
f1e86470ca
7개의 변경된 파일30개의 추가작업 그리고 10개의 파일을 삭제
  1. 6 2
      dist/js/select2.amd.full.js
  2. 6 2
      dist/js/select2.amd.js
  3. 6 2
      dist/js/select2.full.js
  4. 0 0
      dist/js/select2.full.min.js
  5. 6 2
      dist/js/select2.js
  6. 0 0
      dist/js/select2.min.js
  7. 6 2
      src/js/jquery.select2.js

+ 6 - 2
dist/js/select2.amd.full.js

@@ -4065,13 +4065,17 @@ define('jquery.select2',[
 
       if (typeof options === 'object') {
         this.each(function () {
-          var instance = new Select2($(this), options);
+          var instanceOptions = $.extend({}, options, true);
+
+          var instance = new Select2($(this), instanceOptions);
         });
+
+        return this;
       } else if (typeof options === 'string') {
         var instance = this.data('select2');
         var args = Array.prototype.slice.call(arguments, 1);
 
-        instance[options](args);
+        return instance[options](args);
       } else {
         throw new Error('Invalid arguments for Select2: ' + options);
       }

+ 6 - 2
dist/js/select2.amd.js

@@ -4003,13 +4003,17 @@ define('jquery.select2',[
 
       if (typeof options === 'object') {
         this.each(function () {
-          var instance = new Select2($(this), options);
+          var instanceOptions = $.extend({}, options, true);
+
+          var instance = new Select2($(this), instanceOptions);
         });
+
+        return this;
       } else if (typeof options === 'string') {
         var instance = this.data('select2');
         var args = Array.prototype.slice.call(arguments, 1);
 
-        instance[options](args);
+        return instance[options](args);
       } else {
         throw new Error('Invalid arguments for Select2: ' + options);
       }

+ 6 - 2
dist/js/select2.full.js

@@ -13600,13 +13600,17 @@ define('jquery.select2',[
 
       if (typeof options === 'object') {
         this.each(function () {
-          var instance = new Select2($(this), options);
+          var instanceOptions = $.extend({}, options, true);
+
+          var instance = new Select2($(this), instanceOptions);
         });
+
+        return this;
       } else if (typeof options === 'string') {
         var instance = this.data('select2');
         var args = Array.prototype.slice.call(arguments, 1);
 
-        instance[options](args);
+        return instance[options](args);
       } else {
         throw new Error('Invalid arguments for Select2: ' + options);
       }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/js/select2.full.min.js


+ 6 - 2
dist/js/select2.js

@@ -4431,13 +4431,17 @@ define('jquery.select2',[
 
       if (typeof options === 'object') {
         this.each(function () {
-          var instance = new Select2($(this), options);
+          var instanceOptions = $.extend({}, options, true);
+
+          var instance = new Select2($(this), instanceOptions);
         });
+
+        return this;
       } else if (typeof options === 'string') {
         var instance = this.data('select2');
         var args = Array.prototype.slice.call(arguments, 1);
 
-        instance[options](args);
+        return instance[options](args);
       } else {
         throw new Error('Invalid arguments for Select2: ' + options);
       }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/js/select2.min.js


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

@@ -8,13 +8,17 @@ define([
 
       if (typeof options === 'object') {
         this.each(function () {
-          var instance = new Select2($(this), options);
+          var instanceOptions = $.extend({}, options, true);
+
+          var instance = new Select2($(this), instanceOptions);
         });
+
+        return this;
       } else if (typeof options === 'string') {
         var instance = this.data('select2');
         var args = Array.prototype.slice.call(arguments, 1);
 
-        instance[options](args);
+        return instance[options](args);
       } else {
         throw new Error('Invalid arguments for Select2: ' + options);
       }

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.