Skip to content

Commit

Permalink
Fixing an issue related to the ES6 resolver. isolated-container sho…
Browse files Browse the repository at this point in the history
…uld call `resolver.normalize(fullName)` before attempting to lookup and inject `needs` values into the container.
  • Loading branch information
Wesley Workman committed Sep 11, 2014
1 parent f1030c2 commit 566f5bc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion dist/amd/isolated-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ define(
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
Expand Down
3 changes: 2 additions & 1 deletion dist/cjs/isolated-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ exports["default"] = function isolatedContainer(fullNames) {
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
3 changes: 2 additions & 1 deletion dist/globals/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ exports["default"] = function isolatedContainer(fullNames) {
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
Expand Down
3 changes: 2 additions & 1 deletion dist/named-amd/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ define("ember-qunit/isolated-container",
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/isolated-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default function isolatedContainer(fullNames) {
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
var normalizedFullName = resolver.normalize(fullName);
container.register(fullName, resolver.resolve(normalizedFullName));
}
return container;
}
12 changes: 10 additions & 2 deletions test/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ var registry = {
'template:components/pretty-color': 'Pretty Color: <span class="color-name">{{name}}</span>'.compile(),
'route:foo': Ember.Route.extend(),
'controller:foos': Ember.ArrayController.extend(),
'controller:hello-world': Ember.ObjectController.extend(),
'controller:bar': Ember.Controller.extend({
needs: ['foos']
needs: ['foos', 'helloWorld']
}),
'model:post': Post,
'model:comment': Comment,
Expand All @@ -48,6 +49,9 @@ var registry = {
var Resolver = Ember.DefaultResolver.extend({
resolve: function(fullName) {
return registry[fullName] || this._super.apply(this, arguments);
},
normalize: function(fullName) {
return Ember.String.dasherize(fullName);
}
});

Expand All @@ -74,27 +78,31 @@ setResolver(Resolver.create());
//});

moduleFor('controller:bar', 'moduleFor with bar controller', {
needs: ['controller:foos']
needs: ['controller:foos', 'controller:helloWorld']
});

test('exists', function() {
var bar = this.subject();

var foos = bar.get('controllers.foos');
var helloWorld = bar.get('controllers.helloWorld');

ok(bar);
ok(bar instanceof Ember.Controller);
ok(foos instanceof Ember.ArrayController);
ok(helloWorld instanceof Ember.ObjectController);
});

test('exists again', function() {
var bar = this.subject();

var foos = bar.get('controllers.foos');
var helloWorld = bar.get('controllers.helloWorld');

ok(bar);
ok(bar instanceof Ember.Controller);
ok(foos instanceof Ember.ArrayController);
ok(helloWorld instanceof Ember.ObjectController);
});

moduleForModel('whazzit', 'moduleForModel whazzit without adapter');
Expand Down

0 comments on commit 566f5bc

Please sign in to comment.