Skip to content

Commit

Permalink
[BUGFIX beta] Avoid _lazyInjections in production builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Jun 3, 2016
1 parent 4e0c44f commit e9c371a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
16 changes: 9 additions & 7 deletions packages/container/lib/container.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ENV } from 'ember-environment';
import { assert, deprecate } from 'ember-metal/debug';
import { assert, deprecate, runInDebug } from 'ember-metal/debug';
import dictionary from 'ember-metal/dictionary';
import isEnabled from 'ember-metal/features';
import { setOwner, OWNER } from './owner';
Expand Down Expand Up @@ -341,13 +341,15 @@ function instantiate(container, fullName) {

validationCache = container.validationCache;

// Ensure that all lazy injections are valid at instantiation time
if (!validationCache[fullName] && typeof factory._lazyInjections === 'function') {
lazyInjections = factory._lazyInjections();
lazyInjections = container.registry.normalizeInjectionsHash(lazyInjections);
runInDebug(function() {
// Ensure that all lazy injections are valid at instantiation time
if (!validationCache[fullName] && typeof factory._lazyInjections === 'function') {
lazyInjections = factory._lazyInjections();
lazyInjections = container.registry.normalizeInjectionsHash(lazyInjections);

container.registry.validateInjections(lazyInjections);
}
container.registry.validateInjections(lazyInjections);
}
});

validationCache[fullName] = true;

Expand Down
22 changes: 11 additions & 11 deletions packages/ember-runtime/tests/inject_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ if (!EmberDev.runningProdBuild) {
owner.register('foo:main', AnObject);
owner._lookupFactory('foo:main');
});
}

QUnit.test('attempting to inject a nonexistent container key should error', function() {
let owner = buildOwner();
var AnObject = Object.extend({
foo: new InjectedProperty('bar', 'baz')
});
QUnit.test('attempting to inject a nonexistent container key should error', function() {
let owner = buildOwner();
var AnObject = Object.extend({
foo: new InjectedProperty('bar', 'baz')
});

owner.register('foo:main', AnObject);
owner.register('foo:main', AnObject);

throws(function() {
owner.lookup('foo:main');
}, /Attempting to inject an unknown injection: `bar:baz`/);
});
throws(function() {
owner.lookup('foo:main');
}, /Attempting to inject an unknown injection: `bar:baz`/);
});
}

QUnit.test('factories should return a list of lazy injection full names', function() {
var AnObject = Object.extend({
Expand Down

0 comments on commit e9c371a

Please sign in to comment.