perform deep merge for Defaults.set()
This commit is contained in:
parent
6ff10680a6
commit
8398788069
2
src/js/select2/defaults.js
vendored
2
src/js/select2/defaults.js
vendored
@ -387,7 +387,7 @@ define([
|
|||||||
|
|
||||||
var convertedData = Utils._convertData(data);
|
var convertedData = Utils._convertData(data);
|
||||||
|
|
||||||
$.extend(this.defaults, convertedData);
|
$.extend(true, this.defaults, convertedData);
|
||||||
};
|
};
|
||||||
|
|
||||||
var defaults = new Defaults();
|
var defaults = new Defaults();
|
||||||
|
@ -30,3 +30,21 @@ test('options are merged recursively with default options', function (assert) {
|
|||||||
|
|
||||||
defaults.reset();
|
defaults.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('more than one default option can be changed via set()', function(assert) {
|
||||||
|
var defaults = require('select2/defaults');
|
||||||
|
var ajaxDelay = 123;
|
||||||
|
var dataDataType = 'xml'
|
||||||
|
defaults.set('ajax--delay', ajaxDelay);
|
||||||
|
defaults.set('ajax--dataType', dataDataType);
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
defaults.defaults.ajax.delay,
|
||||||
|
ajaxDelay
|
||||||
|
'Both ajax.delay and ajax.dataType present in defaults');
|
||||||
|
assert.equal(
|
||||||
|
defaults.defaults.ajax.dataType,
|
||||||
|
dataDataType,
|
||||||
|
'Both ajax.delay and ajax.dataType present in defaults');
|
||||||
|
defaults.reset();
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user