mirror of
https://github.com/videojs/video.js.git
synced 2025-01-25 11:13:52 +02:00
@heff fixed checking for child options in the parent options to allow for `false`. closes #1630
This commit is contained in:
parent
f420c5bd5f
commit
1325722447
@ -2,7 +2,7 @@ CHANGELOG
|
||||
=========
|
||||
|
||||
## HEAD (Unreleased)
|
||||
_(none)_
|
||||
* @heff fixed checking for child options in the parent options to allow for 'false'; ([view](https://github.com/videojs/video.js/pull/1630))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -490,7 +490,7 @@ vjs.Component.prototype.initChildren = function(){
|
||||
// Allow options for children to be set at the parent options
|
||||
// e.g. videojs(id, { controlBar: false });
|
||||
// instead of videojs(id, { children: { controlBar: false });
|
||||
if (parentOptions[name]) {
|
||||
if (parentOptions[name] !== undefined) {
|
||||
opts = parentOptions[name];
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ test('should do a deep merge of child options', function(){
|
||||
var comp = new vjs.Component(getFakePlayer(), {
|
||||
'example': {
|
||||
'childOne': { 'foo': 'baz', 'abc': '123' },
|
||||
'childThree': null,
|
||||
'childThree': false,
|
||||
'childFour': {}
|
||||
}
|
||||
});
|
||||
@ -88,7 +88,7 @@ test('should do a deep merge of child options', function(){
|
||||
ok(children['childOne']['asdf'] === 'fdsa', 'value three levels deep maintained');
|
||||
ok(children['childOne']['abc'] === '123', 'value three levels deep added');
|
||||
ok(children['childTwo'], 'object two levels deep maintained');
|
||||
ok(children['childThree'] === null, 'object two levels deep removed');
|
||||
ok(children['childThree'] === false, 'object two levels deep removed');
|
||||
ok(children['childFour'], 'object two levels deep added');
|
||||
|
||||
ok(vjs.Component.prototype.options_['example']['childOne']['foo'] === 'bar', 'prototype options were not overridden');
|
||||
@ -98,32 +98,48 @@ test('should do a deep merge of child options', function(){
|
||||
});
|
||||
|
||||
test('should allows setting child options at the parent options level', function(){
|
||||
var parent;
|
||||
var parent, options;
|
||||
|
||||
parent = new vjs.Component(getFakePlayer(), {
|
||||
// using children array
|
||||
options = {
|
||||
'children': [
|
||||
'component'
|
||||
'component',
|
||||
'nullComponent'
|
||||
],
|
||||
// parent-level option for child
|
||||
'component': {
|
||||
'foo': true
|
||||
}
|
||||
});
|
||||
},
|
||||
'nullComponent': false
|
||||
};
|
||||
|
||||
try {
|
||||
parent = new vjs.Component(getFakePlayer(), options);
|
||||
} catch(err) {
|
||||
ok(false, 'Child with `false` option was initialized');
|
||||
}
|
||||
equal(parent.children()[0].options()['foo'], true, 'child options set when children array is used');
|
||||
|
||||
parent = new vjs.Component(getFakePlayer(), {
|
||||
// using children object
|
||||
options = {
|
||||
'children': {
|
||||
'component': {
|
||||
'foo': false
|
||||
}
|
||||
},
|
||||
'nullComponent': {}
|
||||
},
|
||||
// parent-level option for child
|
||||
'component': {
|
||||
'foo': true
|
||||
}
|
||||
});
|
||||
},
|
||||
'nullComponent': false
|
||||
};
|
||||
|
||||
try {
|
||||
parent = new vjs.Component(getFakePlayer(), options);
|
||||
} catch(err) {
|
||||
ok(false, 'Child with `false` option was initialized');
|
||||
}
|
||||
equal(parent.children()[0].options()['foo'], true, 'child options set when children object is used');
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user