1
0
mirror of synced 2024-11-22 04:56:08 +03:00

perform deep merge for Defaults.set()

This commit is contained in:
nobodyman 2016-05-18 15:42:07 -07:00 committed by alexweissman
parent 6ff10680a6
commit 8398788069
2 changed files with 20 additions and 2 deletions

View File

@ -387,7 +387,7 @@ define([
var convertedData = Utils._convertData(data);
$.extend(this.defaults, convertedData);
$.extend(true, this.defaults, convertedData);
};
var defaults = new Defaults();

View File

@ -30,3 +30,21 @@ test('options are merged recursively with default options', function (assert) {
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();
});