From 206379cd57ef0caa07ae72c420c80782f694b231 Mon Sep 17 00:00:00 2001 From: Scott Newcomer Date: Mon, 18 Jan 2021 22:07:12 -0600 Subject: [PATCH] RFC: 680 - Deprecate Implicit Injection on arbitrary Ember Framework objects --- .../extension-support/lib/data_adapter.js | 20 +- .../tests/data_adapter_test.js | 18 +- .../-internals/routing/lib/ext/controller.ts | 10 + .../-internals/routing/lib/system/route.ts | 17 +- .../-internals/routing/lib/system/router.ts | 7 + .../runtime/lib/system/core_object.js | 78 ++++++- .../tests/system/object/create_test.js | 214 +++++++++++++++++- .../@ember/-internals/utils/lib/inspect.ts | 3 + .../@ember/application/lib/application.js | 4 +- .../application/tests/application_test.js | 18 -- .../controller/tests/controller_test.js | 8 + packages/@ember/engine/index.js | 11 - packages/@ember/engine/instance.js | 3 +- packages/@ember/engine/tests/engine_test.js | 16 -- 14 files changed, 352 insertions(+), 75 deletions(-) diff --git a/packages/@ember/-internals/extension-support/lib/data_adapter.js b/packages/@ember/-internals/extension-support/lib/data_adapter.js index eedb6e92d4b..99acb8bd169 100644 --- a/packages/@ember/-internals/extension-support/lib/data_adapter.js +++ b/packages/@ember/-internals/extension-support/lib/data_adapter.js @@ -53,18 +53,18 @@ export default EmberObject.extend({ init() { this._super(...arguments); this.releaseMethods = emberA(); - }, - /** - The container-debug-adapter which is used - to list all models. + /** + The container-debug-adapter which is used + to list all models. - @property containerDebugAdapter - @default undefined - @since 1.5.0 - @public - **/ - containerDebugAdapter: undefined, + @property containerDebugAdapter + @default undefined + @since 1.5.0 + @public + **/ + this.containerDebugAdapter = getOwner(this).lookup('container-debug-adapter:main'); + }, /** The number of attributes to send diff --git a/packages/@ember/-internals/extension-support/tests/data_adapter_test.js b/packages/@ember/-internals/extension-support/tests/data_adapter_test.js index a6ae1f0b28b..fce6bc8eb10 100644 --- a/packages/@ember/-internals/extension-support/tests/data_adapter_test.js +++ b/packages/@ember/-internals/extension-support/tests/data_adapter_test.js @@ -15,13 +15,17 @@ const DataAdapter = EmberDataAdapter.extend({ }, init() { this._super(...arguments); - this.set('containerDebugAdapter', { - canCatalogEntriesByType() { - return true; - }, - catalogEntriesByType() { - return emberA(['post']); - }, + Object.defineProperty(this, 'containerDebugAdapter', { + get() { + return { + canCatalogEntriesByType() { + return true; + }, + catalogEntriesByType() { + return emberA(['post']); + }, + } + } }); }, }); diff --git a/packages/@ember/-internals/routing/lib/ext/controller.ts b/packages/@ember/-internals/routing/lib/ext/controller.ts index f56c36cf6e5..c25eae563eb 100644 --- a/packages/@ember/-internals/routing/lib/ext/controller.ts +++ b/packages/@ember/-internals/routing/lib/ext/controller.ts @@ -1,4 +1,5 @@ import { get } from '@ember/-internals/metal'; +import { getOwner } from '@ember/-internals/owner'; import ControllerMixin from '@ember/controller/lib/controller_mixin'; import { deprecateTransitionMethods, prefixRouteNameArg } from '../utils'; @@ -9,6 +10,15 @@ import { deprecateTransitionMethods, prefixRouteNameArg } from '../utils'; ControllerMixin.reopen({ concatenatedProperties: ['queryParams'], + init() { + this._super(...arguments); + let owner = getOwner(this); + if (owner) { + this.namespace = owner.lookup('application:main'); + this.target = owner.lookup('router:main'); + } + } + /** Defines which query parameters the controller accepts. If you give the names `['category','page']` it will bind diff --git a/packages/@ember/-internals/routing/lib/system/route.ts b/packages/@ember/-internals/routing/lib/system/route.ts index e035cac83b6..b32a1b048b8 100644 --- a/packages/@ember/-internals/routing/lib/system/route.ts +++ b/packages/@ember/-internals/routing/lib/system/route.ts @@ -11,6 +11,7 @@ import { setProperties, } from '@ember/-internals/metal'; import { getOwner, Owner } from '@ember/-internals/owner'; +import { BucketCache } from '@ember/-internals/routing'; import { A as emberA, ActionHandler, @@ -98,8 +99,22 @@ class Route extends EmberObject implements IRoute { controller!: Controller; currentModel: unknown; + _bucketCache: BucketCache | undefined; _internalName!: string; _names: unknown; + _router: EmberRouter | undefined; + + constructor() { + super(...arguments); + + let owner = getOwner(this); + if (owner) { + this._router = owner.lookup('router:main'); + this._bucketCache = owner.lookup('-bucket-cache:main'); + this._topLevelViewTemplate = owner.lookup('template:-outlet'); + this._environment = owner.lookup('-environment:main'); + } + } serialize!: ( model: {}, @@ -110,8 +125,6 @@ class Route extends EmberObject implements IRoute { } | undefined; - _router!: EmberRouter; - /** The name of the route, dot-delimited. diff --git a/packages/@ember/-internals/routing/lib/system/router.ts b/packages/@ember/-internals/routing/lib/system/router.ts index 2a18c8e317d..dff3aa175f8 100644 --- a/packages/@ember/-internals/routing/lib/system/router.ts +++ b/packages/@ember/-internals/routing/lib/system/router.ts @@ -1,5 +1,6 @@ import { OutletState as GlimmerOutletState, OutletView } from '@ember/-internals/glimmer'; import { computed, get, notifyPropertyChange, set } from '@ember/-internals/metal'; +import { BucketCache } from '@ember/-internals/routing'; import { FactoryClass, getOwner, Owner } from '@ember/-internals/owner'; import { A as emberA, Evented, Object as EmberObject, typeOf } from '@ember/-internals/runtime'; import Controller from '@ember/controller'; @@ -138,6 +139,7 @@ class EmberRouter extends EmberObject { _qpUpdates = new Set(); _queuedQPChanges: { [key: string]: unknown } = {}; + _bucketCache: BucketCache | undefined; _toplevelView: OutletView | null = null; _handledErrors = new Set(); _engineInstances: { [name: string]: { [id: string]: EngineInstance } } = Object.create(null); @@ -149,6 +151,11 @@ class EmberRouter extends EmberObject { super(...arguments); this._resetQueuedQueryParameterChanges(); + let owner = getOwner(this); + if (owner) { + this.namespace = owner.lookup('application:main'); + this._bucketCache = owner.lookup('-bucket-cache:main'); + } } _initRouterJs() { diff --git a/packages/@ember/-internals/runtime/lib/system/core_object.js b/packages/@ember/-internals/runtime/lib/system/core_object.js index 4496fcc7194..9fd8dc244fa 100644 --- a/packages/@ember/-internals/runtime/lib/system/core_object.js +++ b/packages/@ember/-internals/runtime/lib/system/core_object.js @@ -9,6 +9,8 @@ import { guidFor, getName, setName, + lookupDescriptor, + inspect, makeArray, HAS_NATIVE_PROXY, HAS_NATIVE_SYMBOL, @@ -28,7 +30,7 @@ import { DEBUG_INJECTION_FUNCTIONS, } from '@ember/-internals/metal'; import ActionHandler from '../mixins/action_handler'; -import { assert } from '@ember/debug'; +import { assert, deprecate } from '@ember/debug'; import { DEBUG } from '@glimmer/env'; import { _WeakSet as WeakSet } from '@glimmer/util'; import { destroy, isDestroying, isDestroyed, registerDestructor } from '@glimmer/destroyable'; @@ -64,6 +66,21 @@ function initialize(obj, properties) { !(properties instanceof Mixin) ); + let injectedProperties; + if (DEBUG) { + // these are all the implicit injectinos + injectedProperties = []; + + let factory = getFactoryFor(obj); + if (factory) { + for (let injection in factory.injections) { + if (factory.injections[injection] === properties[injection]) { + injectedProperties.push(injection); + } + } + } + } + let concatenatedProperties = obj.concatenatedProperties; let mergedProperties = obj.mergedProperties; let hasConcatenatedProps = @@ -73,8 +90,8 @@ function initialize(obj, properties) { let keyNames = Object.keys(properties); for (let i = 0; i < keyNames.length; i++) { - let keyName = keyNames[i]; - let value = properties[keyName]; + var keyName = keyNames[i]; + var value = properties[keyName]; assert( 'EmberObject.create no longer supports defining computed ' + @@ -112,12 +129,48 @@ function initialize(obj, properties) { } if (isDescriptor) { + if (DEBUG) { + // need to check if implicit injection owner.inject('component:my-component', 'foo', 'service:bar') does not match explicit injection @service foo + // implicit injection takes precedence so need to tell user to rename property on obj + let isInjectedProperty = DEBUG_INJECTION_FUNCTIONS.has(possibleDesc._getter); + if (isInjectedProperty && value !== possibleDesc.get(obj, keyName)) { + implicitInjectionDeprecation(keyName, `You have explicitly defined '${keyName}' for ${inspect(obj)} that does not match the implicit injection for '${keyName}'. Please ensure you are explicitly defining '${keyName}' on ${inspect(obj)}.`); + } + } + possibleDesc.set(obj, keyName, value); } else if (typeof obj.setUnknownProperty === 'function' && !(keyName in obj)) { obj.setUnknownProperty(keyName, value); } else { if (DEBUG) { - defineProperty(obj, keyName, null, value, m); // setup mandatory setter + // If deprecation, either 1) an accessor descriptor or 2) class field declaration 3) only an implicit injection + let desc = lookupDescriptor(obj, keyName); + if (!injectedProperties.includes(keyName)) { + defineProperty(obj, keyName, null, value, m); // setup mandatory setter + } else if (desc && desc.get) { + if (value !== desc.get.call(obj)) { + implicitInjectionDeprecation(keyName, `You have defined '${keyName}' for ${inspect(obj)} as a getter which does not match the implicit injection for '${keyName}'. Please migrate to '@service ${keyName}'.`); + } + } else if (desc && desc.value) { + if (desc.value !== value) { + // implicit injection does not match value descriptor set on object + implicitInjectionDeprecation(keyName, `You have defined '${keyName}' for ${inspect(obj)} as a value which does not match the implicit injection for '${keyName}'. Please migrate to '@service ${keyName}'.`); + } + } else { + // wrapper getter for original adding one time deprecation + // TODO add setter + Object.defineProperty(obj, keyName, { + configurable: true, + enumerable: false, + get() { + // only want to deprecate on first access + Object.defineProperty(obj, keyName, { value }); + + implicitInjectionDeprecation(keyName, `Implicit injection for property '${keyName}' is now deprecated. Please add an explicit injection for '${keyName}' to ${inspect(obj)}`); + return value; + } + }); + } } else { obj[keyName] = value; } @@ -1120,4 +1173,21 @@ if (!HAS_NATIVE_SYMBOL) { }); } +// TODO: customize messages and add more debugging info like obj and mismatch information +function implicitInjectionDeprecation(keyName, msg = null) { + deprecate( + msg, + false, + { + id: 'ember-object.implicit-injection', + until: '4.0.0', + url: 'https://', + for: 'ember-source', + since: { + enabled: '3.24.0', + }, + } + ); +} + export default CoreObject; diff --git a/packages/@ember/-internals/runtime/tests/system/object/create_test.js b/packages/@ember/-internals/runtime/tests/system/object/create_test.js index 32d30dbca73..47f79e83f6c 100644 --- a/packages/@ember/-internals/runtime/tests/system/object/create_test.js +++ b/packages/@ember/-internals/runtime/tests/system/object/create_test.js @@ -1,19 +1,229 @@ import { getFactoryFor, Registry } from '@ember/-internals/container'; +import { inspect } from '@ember/-internals/utils'; import { getOwner, setOwner } from '@ember/-internals/owner'; import { computed, Mixin, observer, addObserver, alias } from '@ember/-internals/metal'; +import Service, { inject as service } from '@ember/service'; import { DEBUG } from '@glimmer/env'; import EmberObject from '../../../lib/system/object'; -import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; +import { buildOwner, moduleFor, AbstractTestCase } from 'internal-test-helpers'; import { destroy } from '@glimmer/destroyable'; moduleFor( 'EmberObject.create', class extends AbstractTestCase { ['@test simple properties are set'](assert) { + expectNoDeprecation(); + let o = EmberObject.create({ ohai: 'there' }); assert.equal(o.get('ohai'), 'there'); } + ['@test explicit injection does not raise deprecation'](assert) { + expectNoDeprecation(); + + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + class FooObject extends EmberObject { + @service foo; + } + owner.register('service:foo', FooService); + owner.register('foo:main', FooObject); + + let obj = owner.lookup('foo:main'); + assert.equal(obj.foo.bar, 'foo'); + } + + ['@test implicit injections raises deprecation'](assert) { + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + class FooObject extends EmberObject {} + owner.register('service:foo', FooService); + owner.register('foo:main', FooObject); + owner.inject('foo:main', 'foo', 'service:foo'); + + let obj = owner.lookup('foo:main'); + let result; + expectDeprecation( + () => result = obj.foo, + `Implicit injection for property 'foo' is now deprecated. Please add an explicit injection for 'foo' to ${inspect(obj)}` + ); + + assert.equal(result.bar, 'foo'); + assert.equal(obj.foo.bar, 'foo'); + } + + ['@test implicit injections raises deprecation for old style EmberObject'](assert) { + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + const FooObject = EmberObject.extend(); + owner.register('service:foo', FooService); + owner.register('foo:main', FooObject); + owner.inject('foo:main', 'foo', 'service:foo'); + + let obj = owner.lookup('foo:main'); + let result; + expectDeprecation( + () => result = obj.foo, + `Implicit injection for property 'foo' is now deprecated. Please add an explicit injection for 'foo' to ${inspect(obj)}` + ); + + assert.equal(result.bar, 'foo'); + assert.equal(obj.foo.bar, 'foo'); + } + + ['@test implicit injections does not raise a deprecation if explicit injection present'](assert) { + expectNoDeprecation(); + + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + class FooObject extends EmberObject { + @service foo; + } + owner.register('service:foo', FooService); + owner.register('foo:main', FooObject); + owner.inject('foo:main', 'foo', 'service:foo'); + + let obj = owner.lookup('foo:main'); + assert.equal(obj.foo.bar, 'foo'); + } + + ['@test raises deprecation if explicit injection is not the same as the implicit injection'](assert) { + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + class BarService extends Service { + bar = 'bar'; + } + class FooObject extends EmberObject { + @service foo; + } + owner.register('service:foo', FooService); + owner.register('service:bar', BarService); + owner.register('foo:main', FooObject); + owner.inject('foo:main', 'foo', 'service:bar'); + + let result; + expectDeprecation( + () => result = owner.lookup('foo:main'), + `You have explicitly defined 'foo' for FooObject that does not match the implicit injection for 'foo'. Please ensure you are explicitly defining 'foo' on FooObject.` + ); + assert.equal(result.foo.bar, 'bar'); + } + + ['@test does not raise deprecation if descriptor is a value and equal to the implicit deprecation'](assert) { + expectNoDeprecation(); + + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + class BarService extends Service { + bar = 'bar'; + } + class FooObject extends EmberObject { + foo = getOwner(this).lookup('service:foo'); + } + owner.register('service:foo', FooService); + owner.register('service:bar', BarService); + owner.register('foo:main', FooObject); + owner.inject('foo:main', 'foo', 'service:foo'); + + let result = owner.lookup('foo:main'); + assert.equal(result.foo.bar, 'foo'); + } + + ['@test does raise deprecation if descriptor is a value and not equal to the implicit deprecation'](assert) { + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + class BarService extends Service { + bar = 'bar'; + } + class FooObject extends EmberObject { + foo = getOwner(this).lookup('service:foo'); + } + owner.register('service:foo', FooService); + owner.register('service:bar', BarService); + owner.register('foo:main', FooObject); + owner.inject('foo:main', 'foo', 'service:bar'); + + let result; + expectDeprecation( + () => result = owner.lookup('foo:main'), + `You have defined 'foo' for FooObject as a value which does not match the implicit injection for 'foo'. Please migrate to '@service foo'.` + ); + assert.equal(result.foo.bar, 'foo'); + } + + ['@test does not raise deprecation if descriptor is a getter and equal to the implicit deprecation'](assert) { + expectNoDeprecation(); + + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + class BarService extends Service { + bar = 'bar'; + } + class FooObject extends EmberObject { + get foo() { + return getOwner(this).lookup('service:foo'); + } + } + owner.register('service:foo', FooService); + owner.register('service:bar', BarService); + owner.register('foo:main', FooObject); + owner.inject('foo:main', 'foo', 'service:foo'); + + let result = owner.lookup('foo:main'); + assert.equal(result.foo.bar, 'foo'); + } + + ['@test does raise deprecation if descriptor is a getter and not equal to the implicit deprecation'](assert) { + let owner = buildOwner(); + + class FooService extends Service { + bar = 'foo'; + } + class BarService extends Service { + bar = 'bar'; + } + class FooObject extends EmberObject { + get foo() { + return getOwner(this).lookup('service:foo'); + } + } + owner.register('service:foo', FooService); + owner.register('service:bar', BarService); + owner.register('foo:main', FooObject); + owner.inject('foo:main', 'foo', 'service:bar'); + + let result; + expectDeprecation( + () => result = owner.lookup('foo:main'), + `You have defined 'foo' for FooObject as a getter which does not match the implicit injection for 'foo'. Please migrate to '@service foo'.` + ); + assert.equal(result.foo.bar, 'foo'); + } + ['@test calls computed property setters'](assert) { let MyClass = EmberObject.extend({ foo: computed({ @@ -138,7 +348,7 @@ moduleFor( } } - ['@test calls setUnknownProperty if defined'](assert) { + ['@test calls setUnknownProperty if undefined'](assert) { let setUnknownPropertyCalled = false; let MyClass = EmberObject.extend({ diff --git a/packages/@ember/-internals/utils/lib/inspect.ts b/packages/@ember/-internals/utils/lib/inspect.ts index b03bd695338..376ac6d0a43 100644 --- a/packages/@ember/-internals/utils/lib/inspect.ts +++ b/packages/@ember/-internals/utils/lib/inspect.ts @@ -49,6 +49,9 @@ function inspectValue(value: any | null | undefined, depth: number, seen?: WeakS if (value.toString === objectToString || value.toString === undefined) { break; } + if (value.constructor && value.constructor.name !== 'Class') { + return value.constructor.name; + } // custom toString return value.toString(); case 'function': diff --git a/packages/@ember/application/lib/application.js b/packages/@ember/application/lib/application.js index 9a7ecf82604..a819ea1eefc 100644 --- a/packages/@ember/application/lib/application.js +++ b/packages/@ember/application/lib/application.js @@ -1167,14 +1167,12 @@ function commonSetupRegistry(registry) { registry.register('route:basic', Route); registry.register('event_dispatcher:main', EventDispatcher); - registry.injection('router:main', 'namespace', 'application:main'); - registry.register('location:auto', AutoLocation); registry.register('location:hash', HashLocation); registry.register('location:history', HistoryLocation); registry.register('location:none', NoneLocation); - registry.register(P`-bucket-cache:main`, { + registry.register(`-bucket-cache:main`, { create() { return new BucketCache(); }, diff --git a/packages/@ember/application/tests/application_test.js b/packages/@ember/application/tests/application_test.js index 2bce001fcba..1f8eb2e2d56 100644 --- a/packages/@ember/application/tests/application_test.js +++ b/packages/@ember/application/tests/application_test.js @@ -129,10 +129,8 @@ moduleFor( verifyRegistration(assert, application, 'controller:basic'); verifyRegistration(assert, application, '-view-registry:main'); - verifyInjection(assert, application, 'route', '_topLevelViewTemplate', 'template:-outlet'); verifyRegistration(assert, application, 'route:basic'); verifyRegistration(assert, application, 'event_dispatcher:main'); - verifyInjection(assert, application, 'router:main', 'namespace', 'application:main'); verifyInjection(assert, application, 'view:-outlet', 'namespace', 'application:main'); verifyRegistration(assert, application, 'location:auto'); @@ -140,15 +138,6 @@ moduleFor( verifyRegistration(assert, application, 'location:history'); verifyRegistration(assert, application, 'location:none'); - verifyInjection(assert, application, 'controller', 'target', 'router:main'); - verifyInjection(assert, application, 'controller', 'namespace', 'application:main'); - - verifyRegistration(assert, application, P`-bucket-cache:main`); - verifyInjection(assert, application, 'router', '_bucketCache', P`-bucket-cache:main`); - verifyInjection(assert, application, 'route', '_bucketCache', P`-bucket-cache:main`); - - verifyInjection(assert, application, 'route', '_router', 'router:main'); - verifyRegistration(assert, application, 'component:-text-field'); verifyRegistration(assert, application, 'component:-checkbox'); verifyRegistration(assert, application, 'component:link-to'); @@ -166,13 +155,6 @@ moduleFor( 'resolver', 'resolver-for-debugging:main' ); - verifyInjection( - assert, - application, - 'data-adapter:main', - 'containerDebugAdapter', - 'container-debug-adapter:main' - ); verifyRegistration(assert, application, 'container-debug-adapter:main'); verifyRegistration(assert, application, 'component-lookup:main'); diff --git a/packages/@ember/controller/tests/controller_test.js b/packages/@ember/controller/tests/controller_test.js index 1d456422f6e..3bf7a15441b 100644 --- a/packages/@ember/controller/tests/controller_test.js +++ b/packages/@ember/controller/tests/controller_test.js @@ -2,6 +2,7 @@ import Controller, { inject as injectController } from '@ember/controller'; import Service, { inject as injectService } from '@ember/service'; import { Object as EmberObject } from '@ember/-internals/runtime'; import { Mixin, get } from '@ember/-internals/metal'; +import { setOwner } from '@ember/-internals/owner'; import { runDestroy, buildOwner } from 'internal-test-helpers'; import { moduleFor, ApplicationTestCase, AbstractTestCase, runTask } from 'internal-test-helpers'; import { action } from '@ember/object'; @@ -86,6 +87,8 @@ moduleFor( ['@test A handled action can be bubbled to the target for continued processing'](assert) { assert.expect(2); + let owner = buildOwner(); + let TestController = Controller.extend({ actions: { poke() { @@ -95,6 +98,8 @@ moduleFor( }, }); + owner.register('controller:index', TestController); + let controller = TestController.create({ target: Controller.extend({ actions: { @@ -104,6 +109,9 @@ moduleFor( }, }).create(), }); + + setOwner(controller, owner); + controller.send('poke'); } diff --git a/packages/@ember/engine/index.js b/packages/@ember/engine/index.js index 0ab30e9b50e..73aa2da4914 100644 --- a/packages/@ember/engine/index.js +++ b/packages/@ember/engine/index.js @@ -497,18 +497,8 @@ function commonSetupRegistry(registry) { registry.injection('renderer', '_viewRegistry', '-view-registry:main'); - registry.injection('route', '_topLevelViewTemplate', 'template:-outlet'); - registry.injection('view:-outlet', 'namespace', 'application:main'); - registry.injection('controller', 'target', 'router:main'); - registry.injection('controller', 'namespace', 'application:main'); - - registry.injection('router', '_bucketCache', P`-bucket-cache:main`); - registry.injection('route', '_bucketCache', P`-bucket-cache:main`); - - registry.injection('route', '_router', 'router:main'); - // Register the routing service... registry.register('service:-routing', RoutingService); @@ -517,7 +507,6 @@ function commonSetupRegistry(registry) { instantiate: false, }); registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); - registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); // Custom resolver authors may want to register their own ContainerDebugAdapter with this key registry.register('container-debug-adapter:main', ContainerDebugAdapter); diff --git a/packages/@ember/engine/instance.js b/packages/@ember/engine/instance.js index 3a0693eef08..6a63c058ab7 100644 --- a/packages/@ember/engine/instance.js +++ b/packages/@ember/engine/instance.js @@ -182,7 +182,7 @@ const EngineInstance = EmberObject.extend(RegistryProxyMixin, ContainerProxyMixi let singletons = [ 'router:main', - P`-bucket-cache:main`, + '-bucket-cache:main', '-view-registry:main', `renderer:-dom`, 'service:-document', @@ -213,7 +213,6 @@ EngineInstance.reopenClass({ } registry.injection('view', '_environment', '-environment:main'); - registry.injection('route', '_environment', '-environment:main'); }, }); diff --git a/packages/@ember/engine/tests/engine_test.js b/packages/@ember/engine/tests/engine_test.js index 018b342a4e8..9186d40997e 100644 --- a/packages/@ember/engine/tests/engine_test.js +++ b/packages/@ember/engine/tests/engine_test.js @@ -63,17 +63,8 @@ moduleFor( ); verifyRegistration(assert, engine, 'controller:basic'); verifyInjection(assert, engine, 'renderer', '_viewRegistry', '-view-registry:main'); - verifyInjection(assert, engine, 'route', '_topLevelViewTemplate', 'template:-outlet'); verifyInjection(assert, engine, 'view:-outlet', 'namespace', 'application:main'); - verifyInjection(assert, engine, 'controller', 'target', 'router:main'); - verifyInjection(assert, engine, 'controller', 'namespace', 'application:main'); - - verifyInjection(assert, engine, 'router', '_bucketCache', P`-bucket-cache:main`); - verifyInjection(assert, engine, 'route', '_bucketCache', P`-bucket-cache:main`); - - verifyInjection(assert, engine, 'route', '_router', 'router:main'); - verifyRegistration(assert, engine, 'component:-text-field'); verifyRegistration(assert, engine, 'component:-checkbox'); verifyRegistration(assert, engine, 'component:link-to'); @@ -91,13 +82,6 @@ moduleFor( 'resolver', 'resolver-for-debugging:main' ); - verifyInjection( - assert, - engine, - 'data-adapter:main', - 'containerDebugAdapter', - 'container-debug-adapter:main' - ); verifyRegistration(assert, engine, 'container-debug-adapter:main'); verifyRegistration(assert, engine, 'component-lookup:main');