mirror of
https://github.com/videojs/video.js.git
synced 2025-07-15 01:34:23 +02:00
fix: addChild instance names should be toTitleCased (#4116)
This commit is contained in:
@ -418,7 +418,7 @@ class Component {
|
|||||||
|
|
||||||
// If a name wasn't used to create the component, check if we can use the
|
// If a name wasn't used to create the component, check if we can use the
|
||||||
// name function of the component
|
// name function of the component
|
||||||
componentName = componentName || (component.name && component.name());
|
componentName = componentName || (component.name && toTitleCase(component.name()));
|
||||||
|
|
||||||
if (componentName) {
|
if (componentName) {
|
||||||
this.childNameIndex_[componentName] = component;
|
this.childNameIndex_[componentName] = component;
|
||||||
|
@ -140,6 +140,19 @@ QUnit.test('addChild should throw if the child does not exist', function(assert)
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('addChild with instance should allow getting child correctly', function(assert) {
|
||||||
|
const comp = new Component(getFakePlayer());
|
||||||
|
const comp2 = new Component(getFakePlayer());
|
||||||
|
|
||||||
|
comp2.name = function() {
|
||||||
|
return 'foo';
|
||||||
|
};
|
||||||
|
|
||||||
|
comp.addChild(comp2);
|
||||||
|
assert.ok(comp.getChild('foo'), 'we can get child with camelCase');
|
||||||
|
assert.ok(comp.getChild('Foo'), 'we can get child with TitleCase');
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should add a child component with title case name', function(assert) {
|
QUnit.test('should add a child component with title case name', function(assert) {
|
||||||
const comp = new Component(getFakePlayer());
|
const comp = new Component(getFakePlayer());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user