Skip to content

Commit

Permalink
fix: addChild instance names should be toTitleCased (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev committed Feb 22, 2017
1 parent b5727a6 commit fa97309
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class Component {

// If a name wasn't used to create the component, check if we can use the
// name function of the component
componentName = componentName || (component.name && component.name());
componentName = componentName || (component.name && toTitleCase(component.name()));

if (componentName) {
this.childNameIndex_[componentName] = component;
Expand Down
13 changes: 13 additions & 0 deletions test/unit/component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,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) {
const comp = new Component(getFakePlayer());

Expand Down

0 comments on commit fa97309

Please sign in to comment.