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.
This commit is contained in:
parent
12f7ed93f8
commit
f1e86470ca
8
dist/js/select2.amd.full.js
vendored
8
dist/js/select2.amd.full.js
vendored
@ -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);
|
||||
}
|
||||
|
8
dist/js/select2.amd.js
vendored
8
dist/js/select2.amd.js
vendored
@ -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);
|
||||
}
|
||||
|
8
dist/js/select2.full.js
vendored
8
dist/js/select2.full.js
vendored
@ -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);
|
||||
}
|
||||
|
2
dist/js/select2.full.min.js
vendored
2
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
8
dist/js/select2.js
vendored
8
dist/js/select2.js
vendored
@ -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);
|
||||
}
|
||||
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user