Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Avoid _lazyInjections in production builds. #13590

Merged
merged 1 commit into from
Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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