From 68b916365745658841df1a9c19118d8f5ca7db60 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Tue, 21 Feb 2017 17:05:28 -0500 Subject: [PATCH 1/2] fix: addChild instance names should be toTitleCased --- src/js/component.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/component.js b/src/js/component.js index a9db8596f5..d3ca172ecd 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -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; From 88550c0f6d9f0f78693faff951437dade58edef8 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Tue, 21 Feb 2017 18:33:27 -0500 Subject: [PATCH 2/2] add a test --- test/unit/component.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/unit/component.test.js b/test/unit/component.test.js index 20c253c56f..1c8792422e 100644 --- a/test/unit/component.test.js +++ b/test/unit/component.test.js @@ -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());