Skip to content

Commit

Permalink
Add support for nested colocated components.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Sep 24, 2019
1 parent 98dc24f commit e63891d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion addon/resolvers/classic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ const Resolver = EmberObject.extend({
return parsedName.prefix + '/' + this.pluralize(parsedName.type) + '/' + parsedName.fullNameWithoutType;
},

nestedColocationComponentModuleName(parsedName) {
if (parsedName.type === 'component') {
return parsedName.prefix + '/' + this.pluralize(parsedName.type) + '/' + parsedName.fullNameWithoutType + '/index';
}
},

prefix(parsedName) {
let tmpPrefix = this.namespace.modulePrefix;

Expand All @@ -285,7 +291,8 @@ const Resolver = EmberObject.extend({
this.podBasedModuleName,
this.podBasedComponentsInSubdir,
this.mainModuleName,
this.defaultModuleName
this.defaultModuleName,
this.nestedColocationComponentModuleName,
];
}).readOnly(),

Expand Down
10 changes: 10 additions & 0 deletions tests/unit/resolvers/classic/basic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,16 @@ test("will not use custom type prefix when using POD format", function(assert) {
resolver.resolve('controller:foo');
});

test('it will find components nested in app/components/name/index.js', function(assert) {
define('appkit/components/foo-bar/index', [], function(){
assert.ok(true, 'appkit/components/foo-bar was used');

return 'whatever';
});

resolver.resolve('component:foo-bar');
});

test("will lookup a components template without being rooted in `components/`", function(assert) {
define('appkit/components/foo-bar/template', [], function(){
assert.ok(false, 'appkit/components was used');
Expand Down

0 comments on commit e63891d

Please sign in to comment.