From a805d843e007f6e58c7331d811fb6a2e26fe0f1d Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Fri, 7 Feb 2020 15:14:55 -0800 Subject: [PATCH] [BUGFIX lts] Revert container deprecation We agreed that it was important to fix the error cases in #18717, but while the work may be unnecessary, there isn't necessarily any "correctness" issues with looking up things during destruction. Using a deprecation to warn about potentially "unnecessary" work is a bit heavy-handed, and at minimum requires some more continued discussions, so reverting that part of the PR for now (while keeping the errors in tact). (cherry picked from commit b853324e9250434471da352fd766ae53d4f2321f) --- .../-internals/container/lib/container.ts | 10 +-- .../container/tests/container_test.js | 69 ------------------- 2 files changed, 1 insertion(+), 78 deletions(-) diff --git a/packages/@ember/-internals/container/lib/container.ts b/packages/@ember/-internals/container/lib/container.ts index 23996f7b198..63d1ae55ae7 100644 --- a/packages/@ember/-internals/container/lib/container.ts +++ b/packages/@ember/-internals/container/lib/container.ts @@ -1,7 +1,7 @@ import { Factory, LookupOptions, Owner, OWNER, setOwner } from '@ember/-internals/owner'; import { dictionary, HAS_NATIVE_PROXY } from '@ember/-internals/utils'; import { EMBER_MODULE_UNIFICATION } from '@ember/canary-features'; -import { assert, deprecate } from '@ember/debug'; +import { assert } from '@ember/debug'; import { assign } from '@ember/polyfills'; import { DEBUG } from '@glimmer/env'; import Registry, { DebugRegistry, Injection } from './registry'; @@ -584,14 +584,6 @@ class FactoryManager { ); } - if (DEBUG) { - deprecate( - `Instantiating a new instance of ${this.fullName} while the owner is being destroyed is deprecated.`, - !container.isDestroying, - { id: 'container.lookup-on-destroy', until: '3.20.0' } - ); - } - let injectionsCache = this.injections; if (injectionsCache === undefined) { let { injections, isDynamic } = injectionsFor(this.container, this.normalizedName); diff --git a/packages/@ember/-internals/container/tests/container_test.js b/packages/@ember/-internals/container/tests/container_test.js index f0b5582b1a6..7a643991894 100644 --- a/packages/@ember/-internals/container/tests/container_test.js +++ b/packages/@ember/-internals/container/tests/container_test.js @@ -736,75 +736,6 @@ moduleFor( assert.deepEqual(Object.keys(instance), []); } - '@test instantiating via container.lookup during destruction emits a deprecation'(assert) { - let registry = new Registry(); - let container = registry.container(); - class Service extends factory() { - destroy() { - expectDeprecation(() => { - container.lookup('service:other'); - }, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/); - } - } - registry.register('service:foo', Service); - registry.register('service:other', factory()); - let instance = container.lookup('service:foo'); - assert.ok(instance, 'precond lookup successful'); - - runTask(() => { - container.destroy(); - container.finalizeDestroy(); - }); - } - - '@test instantiating via container.lookup during destruction enqueues destruction'(assert) { - let registry = new Registry(); - let container = registry.container(); - let otherInstance; - class Service extends factory() { - destroy() { - expectDeprecation(() => { - otherInstance = container.lookup('service:other'); - }, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/); - - assert.ok(otherInstance.isDestroyed, 'service:other was destroyed'); - } - } - registry.register('service:foo', Service); - registry.register('service:other', factory()); - let instance = container.lookup('service:foo'); - assert.ok(instance, 'precond lookup successful'); - - runTask(() => { - container.destroy(); - container.finalizeDestroy(); - }); - } - - '@test instantiating via container.factoryFor().create() during destruction emits a deprecation'( - assert - ) { - let registry = new Registry(); - let container = registry.container(); - class Service extends factory() { - destroy() { - expectDeprecation(() => { - let Factory = container.factoryFor('service:other'); - Factory.create(); - }, /Instantiating a new instance of service:other while the owner is being destroyed is deprecated/); - } - } - registry.register('service:foo', Service); - registry.register('service:other', factory()); - let instance = container.lookup('service:foo'); - assert.ok(instance, 'precond lookup successful'); - - runTask(() => { - container.destroy(); - container.finalizeDestroy(); - }); - } - '@test instantiating via container.factoryFor().create() after destruction throws an error'( assert ) {