diff --git a/features.json b/features.json
index 09af55ce7ad..05798433f8f 100644
--- a/features.json
+++ b/features.json
@@ -3,7 +3,6 @@
"features-stripped-test": null,
"ember-routing-route-configured-query-params": null,
"ember-libraries-isregistered": null,
- "ember-application-engines": true,
"ember-runtime-computed-uniq-by": true,
"ember-improved-instrumentation": null,
"ember-runtime-enumerable-includes": true,
diff --git a/packages/ember-application/lib/index.js b/packages/ember-application/lib/index.js
index 1b7a6bae0d8..5a527378670 100644
--- a/packages/ember-application/lib/index.js
+++ b/packages/ember-application/lib/index.js
@@ -1,5 +1,4 @@
import Ember from 'ember-metal/core'; // reexports
-import isEnabled from 'ember-metal/features';
import { runLoadHooks } from 'ember-runtime/system/lazy_load';
/**
@@ -17,17 +16,11 @@ import Engine from './system/engine';
import EngineInstance from './system/engine-instance';
Ember.Application = Application;
+Ember.ApplicationInstance = ApplicationInstance;
+Ember.Engine = Engine;
+Ember.EngineInstance = EngineInstance;
Ember.DefaultResolver = Ember.Resolver = DefaultResolver;
-if (isEnabled('ember-application-engines')) {
- Ember.Engine = Engine;
-
- // Expose `EngineInstance` and `ApplicationInstance` for easy overriding.
- // Reanalyze whether to continue exposing these after feature flag is removed.
- Ember.EngineInstance = EngineInstance;
- Ember.ApplicationInstance = ApplicationInstance;
-}
-
// add domTemplates initializer (only does something if `ember-template-compiler`
// is loaded already)
import './initializers/dom-templates';
diff --git a/packages/ember-application/lib/system/engine-instance.js b/packages/ember-application/lib/system/engine-instance.js
index 622103e39ee..3d32ee5ad2f 100644
--- a/packages/ember-application/lib/system/engine-instance.js
+++ b/packages/ember-application/lib/system/engine-instance.js
@@ -14,7 +14,6 @@ import { assert } from 'ember-metal/debug';
import run from 'ember-metal/run_loop';
import RSVP from 'ember-runtime/ext/rsvp';
import { guidFor } from 'ember-metal/utils';
-import isEnabled from 'ember-metal/features';
/**
The `EngineInstance` encapsulates all of the stateful aspects of a
@@ -25,7 +24,6 @@ import isEnabled from 'ember-metal/features';
@extends Ember.Object
@uses RegistryProxyMixin
@uses ContainerProxyMixin
- @category ember-application-engines
*/
const EngineInstance = EmberObject.extend(RegistryProxy, ContainerProxy, {
@@ -101,9 +99,7 @@ const EngineInstance = EmberObject.extend(RegistryProxy, ContainerProxy, {
assert('An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.', getEngineParent(this));
- if (isEnabled('ember-application-engines')) {
- this.cloneParentDependencies();
- }
+ this.cloneParentDependencies();
this.setupRegistry(options);
@@ -139,6 +135,66 @@ const EngineInstance = EmberObject.extend(RegistryProxy, ContainerProxy, {
willDestroy() {
this._super(...arguments);
run(this.__container__, 'destroy');
+ },
+
+ /**
+ Build a new `Ember.EngineInstance` that's a child of this instance.
+
+ Engines must be registered by name with their parent engine
+ (or application).
+
+ @private
+ @method buildChildEngineInstance
+ @param name {String} the registered name of the engine.
+ @param options {Object} options provided to the engine instance.
+ @return {Ember.EngineInstance,Error}
+ */
+ buildChildEngineInstance(name, options = {}) {
+ let Engine = this.lookup(`engine:${name}`);
+
+ if (!Engine) {
+ throw new EmberError(`You attempted to mount the engine '${name}', but it is not registered with its parent.`);
+ }
+
+ let engineInstance = Engine.buildInstance(options);
+
+ setEngineParent(engineInstance, this);
+
+ return engineInstance;
+ },
+
+ /**
+ Clone dependencies shared between an engine instance and its parent.
+
+ @private
+ @method cloneParentDependencies
+ */
+ cloneParentDependencies() {
+ let parent = getEngineParent(this);
+
+ let registrations = [
+ 'route:basic',
+ 'event_dispatcher:main',
+ 'service:-routing',
+ 'service:-glimmer-environment'
+ ];
+
+ registrations.forEach(key => this.register(key, parent.resolveRegistration(key)));
+
+ let env = parent.lookup('-environment:main');
+ this.register('-environment:main', env, { instantiate: false });
+
+ let singletons = [
+ 'router:main',
+ P`-bucket-cache:main`,
+ '-view-registry:main',
+ `renderer:-${env.isInteractive ? 'dom' : 'inert'}`
+ ];
+
+ singletons.forEach(key => this.register(key, parent.lookup(key), { instantiate: false }));
+
+ this.inject('view', '_environment', '-environment:main');
+ this.inject('route', '_environment', '-environment:main');
}
});
@@ -166,68 +222,4 @@ EngineInstance.reopenClass({
}
});
-if (isEnabled('ember-application-engines')) {
- EngineInstance.reopen({
- /**
- Build a new `Ember.EngineInstance` that's a child of this instance.
-
- Engines must be registered by name with their parent engine
- (or application).
-
- @private
- @method buildChildEngineInstance
- @param name {String} the registered name of the engine.
- @param options {Object} options provided to the engine instance.
- @return {Ember.EngineInstance,Error}
- */
- buildChildEngineInstance(name, options = {}) {
- let Engine = this.lookup(`engine:${name}`);
-
- if (!Engine) {
- throw new EmberError(`You attempted to mount the engine '${name}', but it is not registered with its parent.`);
- }
-
- let engineInstance = Engine.buildInstance(options);
-
- setEngineParent(engineInstance, this);
-
- return engineInstance;
- },
-
- /**
- Clone dependencies shared between an engine instance and its parent.
-
- @private
- @method cloneParentDependencies
- */
- cloneParentDependencies() {
- let parent = getEngineParent(this);
-
- let registrations = [
- 'route:basic',
- 'event_dispatcher:main',
- 'service:-routing',
- 'service:-glimmer-environment'
- ];
-
- registrations.forEach(key => this.register(key, parent.resolveRegistration(key)));
-
- let env = parent.lookup('-environment:main');
- this.register('-environment:main', env, { instantiate: false });
-
- let singletons = [
- 'router:main',
- P`-bucket-cache:main`,
- '-view-registry:main',
- `renderer:-${env.isInteractive ? 'dom' : 'inert'}`
- ];
-
- singletons.forEach(key => this.register(key, parent.lookup(key), { instantiate: false }));
-
- this.inject('view', '_environment', '-environment:main');
- this.inject('route', '_environment', '-environment:main');
- }
- });
-}
-
export default EngineInstance;
diff --git a/packages/ember-application/lib/system/engine.js b/packages/ember-application/lib/system/engine.js
index 530075cf57a..d80f572b974 100644
--- a/packages/ember-application/lib/system/engine.js
+++ b/packages/ember-application/lib/system/engine.js
@@ -47,7 +47,6 @@ function props(obj) {
@namespace Ember
@extends Ember.Namespace
@uses RegistryProxy
- @category ember-application-engines
@public
*/
const Engine = Namespace.extend(RegistryProxy, {
diff --git a/packages/ember-application/tests/system/application_instance_test.js b/packages/ember-application/tests/system/application_instance_test.js
index 721c8d6fe3d..20c0072a1fe 100644
--- a/packages/ember-application/tests/system/application_instance_test.js
+++ b/packages/ember-application/tests/system/application_instance_test.js
@@ -4,7 +4,6 @@ import ApplicationInstance from 'ember-application/system/application-instance';
import run from 'ember-metal/run_loop';
import jQuery from 'ember-views/system/jquery';
import factory from 'container/tests/test-helpers/factory';
-import isEnabled from 'ember-metal/features';
import { privatize as P } from 'container';
import EmberObject from 'ember-runtime/system/object';
@@ -139,67 +138,65 @@ QUnit.test('unregistering a factory clears all cached instances of that factory'
assert.notStrictEqual(postController1, postController2, 'lookup creates a brand new instance, because the previous one was reset');
});
-if (isEnabled('ember-application-engines')) {
- QUnit.test('can build and boot a registered engine', function(assert) {
- assert.expect(10);
+QUnit.test('can build and boot a registered engine', function(assert) {
+ assert.expect(10);
- let ChatEngine = Engine.extend();
- let chatEngineInstance;
+ let ChatEngine = Engine.extend();
+ let chatEngineInstance;
- application.register('engine:chat', ChatEngine);
+ application.register('engine:chat', ChatEngine);
- run(() => {
- appInstance = ApplicationInstance.create({ application });
- appInstance.setupRegistry();
- chatEngineInstance = appInstance.buildChildEngineInstance('chat');
- });
+ run(() => {
+ appInstance = ApplicationInstance.create({ application });
+ appInstance.setupRegistry();
+ chatEngineInstance = appInstance.buildChildEngineInstance('chat');
+ });
- return chatEngineInstance.boot()
- .then(() => {
- assert.ok(true, 'boot successful');
-
- let registrations = [
- 'route:basic',
- 'event_dispatcher:main',
- 'service:-routing',
- 'service:-glimmer-environment'
- ];
-
- registrations.forEach(key => {
- assert.strictEqual(
- chatEngineInstance.resolveRegistration(key),
- appInstance.resolveRegistration(key),
- `Engine and parent app share registrations for '${key}'`);
- });
-
- let singletons = [
- 'router:main',
- P`-bucket-cache:main`,
- '-view-registry:main',
- '-environment:main'
- ];
-
- let env = appInstance.lookup('-environment:main');
- singletons.push(env.isInteractive ? 'renderer:-dom' : 'renderer:-inert');
-
- singletons.forEach(key => {
- assert.strictEqual(
- chatEngineInstance.lookup(key),
- appInstance.lookup(key),
- `Engine and parent app share singleton '${key}'`);
- });
+ return chatEngineInstance.boot()
+ .then(() => {
+ assert.ok(true, 'boot successful');
+
+ let registrations = [
+ 'route:basic',
+ 'event_dispatcher:main',
+ 'service:-routing',
+ 'service:-glimmer-environment'
+ ];
+
+ registrations.forEach(key => {
+ assert.strictEqual(
+ chatEngineInstance.resolveRegistration(key),
+ appInstance.resolveRegistration(key),
+ `Engine and parent app share registrations for '${key}'`);
});
- });
- QUnit.test('can build a registry via Ember.ApplicationInstance.setupRegistry() -- simulates ember-test-helpers', function(assert) {
- let namespace = EmberObject.create({
- Resolver: { create: function() { } }
+ let singletons = [
+ 'router:main',
+ P`-bucket-cache:main`,
+ '-view-registry:main',
+ '-environment:main'
+ ];
+
+ let env = appInstance.lookup('-environment:main');
+ singletons.push(env.isInteractive ? 'renderer:-dom' : 'renderer:-inert');
+
+ singletons.forEach(key => {
+ assert.strictEqual(
+ chatEngineInstance.lookup(key),
+ appInstance.lookup(key),
+ `Engine and parent app share singleton '${key}'`);
+ });
});
+});
- let registry = Application.buildRegistry(namespace);
+QUnit.test('can build a registry via Ember.ApplicationInstance.setupRegistry() -- simulates ember-test-helpers', function(assert) {
+ let namespace = EmberObject.create({
+ Resolver: { create: function() { } }
+ });
- ApplicationInstance.setupRegistry(registry);
+ let registry = Application.buildRegistry(namespace);
- assert.equal(registry.resolve('service:-document'), document);
- });
-}
+ ApplicationInstance.setupRegistry(registry);
+
+ assert.equal(registry.resolve('service:-document'), document);
+});
diff --git a/packages/ember-application/tests/system/engine_instance_test.js b/packages/ember-application/tests/system/engine_instance_test.js
index 1f17fb85bac..72737616cad 100644
--- a/packages/ember-application/tests/system/engine_instance_test.js
+++ b/packages/ember-application/tests/system/engine_instance_test.js
@@ -3,7 +3,6 @@ import EngineInstance from 'ember-application/system/engine-instance';
import { getEngineParent, setEngineParent } from 'ember-application/system/engine-parent';
import run from 'ember-metal/run_loop';
import factory from 'container/tests/test-helpers/factory';
-import isEnabled from 'ember-metal/features';
let engine, engineInstance;
@@ -55,49 +54,47 @@ QUnit.test('unregistering a factory clears all cached instances of that factory'
assert.notStrictEqual(postComponent1, postComponent2, 'lookup creates a brand new instance because previous one was reset');
});
-if (isEnabled('ember-application-engines')) {
- QUnit.test('can be booted when its parent has been set', function(assert) {
- assert.expect(3);
+QUnit.test('can be booted when its parent has been set', function(assert) {
+ assert.expect(3);
- engineInstance = run(() => EngineInstance.create({ base: engine }));
+ engineInstance = run(() => EngineInstance.create({ base: engine }));
- expectAssertion(() => {
- engineInstance._bootSync();
- }, 'An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.');
+ expectAssertion(() => {
+ engineInstance._bootSync();
+ }, 'An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.');
- setEngineParent(engineInstance, {});
+ setEngineParent(engineInstance, {});
- // Stub `cloneParentDependencies`, the internals of which are tested along
- // with application instances.
- engineInstance.cloneParentDependencies = function() {
- assert.ok(true, 'parent dependencies are cloned');
- };
+ // Stub `cloneParentDependencies`, the internals of which are tested along
+ // with application instances.
+ engineInstance.cloneParentDependencies = function() {
+ assert.ok(true, 'parent dependencies are cloned');
+ };
- return engineInstance.boot().then(() => {
- assert.ok(true, 'boot successful');
- });
+ return engineInstance.boot().then(() => {
+ assert.ok(true, 'boot successful');
});
+});
- QUnit.test('can build a child instance of a registered engine', function(assert) {
- let ChatEngine = Engine.extend();
- let chatEngineInstance;
+QUnit.test('can build a child instance of a registered engine', function(assert) {
+ let ChatEngine = Engine.extend();
+ let chatEngineInstance;
- engine.register('engine:chat', ChatEngine);
+ engine.register('engine:chat', ChatEngine);
- run(() => {
- engineInstance = EngineInstance.create({ base: engine });
+ run(() => {
+ engineInstance = EngineInstance.create({ base: engine });
- // Try to build an unregistered engine.
- throws(() => {
- engineInstance.buildChildEngineInstance('fake');
- }, `You attempted to mount the engine 'fake', but it is not registered with its parent.`);
+ // Try to build an unregistered engine.
+ throws(() => {
+ engineInstance.buildChildEngineInstance('fake');
+ }, `You attempted to mount the engine 'fake', but it is not registered with its parent.`);
- // Build the `chat` engine, registered above.
- chatEngineInstance = engineInstance.buildChildEngineInstance('chat');
- });
+ // Build the `chat` engine, registered above.
+ chatEngineInstance = engineInstance.buildChildEngineInstance('chat');
+ });
- assert.ok(chatEngineInstance, 'child engine instance successfully created');
+ assert.ok(chatEngineInstance, 'child engine instance successfully created');
- assert.strictEqual(getEngineParent(chatEngineInstance), engineInstance, 'child engine instance is assigned the correct parent');
- });
-}
+ assert.strictEqual(getEngineParent(chatEngineInstance), engineInstance, 'child engine instance is assigned the correct parent');
+});
diff --git a/packages/ember-glimmer/tests/integration/application/engine-test.js b/packages/ember-glimmer/tests/integration/application/engine-test.js
index b19fbaa28e5..5ea1eec5c46 100644
--- a/packages/ember-glimmer/tests/integration/application/engine-test.js
+++ b/packages/ember-glimmer/tests/integration/application/engine-test.js
@@ -4,149 +4,144 @@ import { compile } from '../../utils/helpers';
import Controller from 'ember-runtime/controllers/controller';
import Engine from 'ember-application/system/engine';
import Route from 'ember-routing/system/route';
-import isEnabled from 'ember-metal/features';
-
-const shouldRun = isEnabled('ember-application-engines');
-
-if (shouldRun) {
- moduleFor('Application test: engine rendering', class extends ApplicationTest {
- setupAppAndRoutableEngine(hooks = []) {
- this.application.register('template:application', compile('Application{{outlet}}'));
-
- this.router.map(function() {
- this.mount('blog');
- });
- this.application.register('route-map:blog', function() { });
- this.registerRoute('application', Route.extend({
- model() {
- hooks.push('application - application');
- }
- }));
-
- this.registerEngine('blog', Engine.extend({
- init() {
- this._super(...arguments);
- this.register('template:application', compile('Engine{{outlet}}'));
- this.register('route:application', Route.extend({
- model() {
- hooks.push('engine - application');
- }
- }));
- }
- }));
- }
-
- setupAppAndRoutelessEngine(hooks) {
- this.application.register('template:application', compile('Application{{mount "chat-engine"}}'));
- this.registerRoute('application', Route.extend({
- model() {
- hooks.push('application - application');
- }
- }));
-
- this.registerEngine('chat-engine', Engine.extend({
- init() {
- this._super(...arguments);
- this.register('template:application', compile('Engine'));
- this.register('controller:application', Controller.extend({
- init() {
- this._super(...arguments);
- hooks.push('engine - application');
- }
- }));
- }
- }));
- }
-
- ['@test sharing a template between engine and application has separate refinements']() {
- this.assert.expect(1);
-
- let sharedTemplate = compile(strip`
-
{{contextType}}
- {{ambiguous-curlies}}
-
- {{outlet}}
- `);
-
- this.application.register('template:application', sharedTemplate);
- this.registerController('application', Controller.extend({
- contextType: 'Application',
- 'ambiguous-curlies': 'Controller Data!'
- }));
-
- this.router.map(function() {
- this.mount('blog');
- });
- this.application.register('route-map:blog', function() { });
-
- this.registerEngine('blog', Engine.extend({
- init() {
- this._super(...arguments);
-
- this.register('controller:application', Controller.extend({
- contextType: 'Engine'
- }));
- this.register('template:application', sharedTemplate);
- this.register('template:components/ambiguous-curlies', compile(strip`
- Component!
- `));
- }
- }));
-
- return this.visit('/blog').then(() => {
- this.assertText('ApplicationController Data!EngineComponent!');
- });
- }
-
- ['@test visit() with `shouldRender: true` returns a promise that resolves when application and engine templates have rendered'](assert) {
- assert.expect(2);
-
- let hooks = [];
-
- this.setupAppAndRoutableEngine(hooks);
-
- return this.visit('/blog', { shouldRender: true }).then(() => {
- this.assertText('ApplicationEngine');
-
- this.assert.deepEqual(hooks, [
- 'application - application',
- 'engine - application'
- ], 'the expected model hooks were fired');
- });
- }
-
- ['@test visit() with `shouldRender: false` returns a promise that resolves without rendering'](assert) {
- assert.expect(2);
-
- let hooks = [];
-
- this.setupAppAndRoutableEngine(hooks);
-
- return this.visit('/blog', { shouldRender: false }).then(() => {
- this.assertText('');
-
- this.assert.deepEqual(hooks, [
- 'application - application',
- 'engine - application'
- ], 'the expected model hooks were fired');
- });
- }
-
- ['@test visit() with `shouldRender: true` returns a promise that resolves when application and routeless engine templates have rendered'](assert) {
- assert.expect(2);
-
- let hooks = [];
-
- this.setupAppAndRoutelessEngine(hooks);
-
- return this.visit('/', { shouldRender: true }).then(() => {
- this.assertText('ApplicationEngine');
-
- this.assert.deepEqual(hooks, [
- 'application - application',
- 'engine - application'
- ], 'the expected hooks were fired');
- });
- }
- });
-}
+
+moduleFor('Application test: engine rendering', class extends ApplicationTest {
+ setupAppAndRoutableEngine(hooks = []) {
+ this.application.register('template:application', compile('Application{{outlet}}'));
+
+ this.router.map(function() {
+ this.mount('blog');
+ });
+ this.application.register('route-map:blog', function() { });
+ this.registerRoute('application', Route.extend({
+ model() {
+ hooks.push('application - application');
+ }
+ }));
+
+ this.registerEngine('blog', Engine.extend({
+ init() {
+ this._super(...arguments);
+ this.register('template:application', compile('Engine{{outlet}}'));
+ this.register('route:application', Route.extend({
+ model() {
+ hooks.push('engine - application');
+ }
+ }));
+ }
+ }));
+ }
+
+ setupAppAndRoutelessEngine(hooks) {
+ this.application.register('template:application', compile('Application{{mount "chat-engine"}}'));
+ this.registerRoute('application', Route.extend({
+ model() {
+ hooks.push('application - application');
+ }
+ }));
+
+ this.registerEngine('chat-engine', Engine.extend({
+ init() {
+ this._super(...arguments);
+ this.register('template:application', compile('Engine'));
+ this.register('controller:application', Controller.extend({
+ init() {
+ this._super(...arguments);
+ hooks.push('engine - application');
+ }
+ }));
+ }
+ }));
+ }
+
+ ['@test sharing a template between engine and application has separate refinements']() {
+ this.assert.expect(1);
+
+ let sharedTemplate = compile(strip`
+ {{contextType}}
+ {{ambiguous-curlies}}
+
+ {{outlet}}
+ `);
+
+ this.application.register('template:application', sharedTemplate);
+ this.registerController('application', Controller.extend({
+ contextType: 'Application',
+ 'ambiguous-curlies': 'Controller Data!'
+ }));
+
+ this.router.map(function() {
+ this.mount('blog');
+ });
+ this.application.register('route-map:blog', function() { });
+
+ this.registerEngine('blog', Engine.extend({
+ init() {
+ this._super(...arguments);
+
+ this.register('controller:application', Controller.extend({
+ contextType: 'Engine'
+ }));
+ this.register('template:application', sharedTemplate);
+ this.register('template:components/ambiguous-curlies', compile(strip`
+ Component!
+ `));
+ }
+ }));
+
+ return this.visit('/blog').then(() => {
+ this.assertText('ApplicationController Data!EngineComponent!');
+ });
+ }
+
+ ['@test visit() with `shouldRender: true` returns a promise that resolves when application and engine templates have rendered'](assert) {
+ assert.expect(2);
+
+ let hooks = [];
+
+ this.setupAppAndRoutableEngine(hooks);
+
+ return this.visit('/blog', { shouldRender: true }).then(() => {
+ this.assertText('ApplicationEngine');
+
+ this.assert.deepEqual(hooks, [
+ 'application - application',
+ 'engine - application'
+ ], 'the expected model hooks were fired');
+ });
+ }
+
+ ['@test visit() with `shouldRender: false` returns a promise that resolves without rendering'](assert) {
+ assert.expect(2);
+
+ let hooks = [];
+
+ this.setupAppAndRoutableEngine(hooks);
+
+ return this.visit('/blog', { shouldRender: false }).then(() => {
+ this.assertText('');
+
+ this.assert.deepEqual(hooks, [
+ 'application - application',
+ 'engine - application'
+ ], 'the expected model hooks were fired');
+ });
+ }
+
+ ['@test visit() with `shouldRender: true` returns a promise that resolves when application and routeless engine templates have rendered'](assert) {
+ assert.expect(2);
+
+ let hooks = [];
+
+ this.setupAppAndRoutelessEngine(hooks);
+
+ return this.visit('/', { shouldRender: true }).then(() => {
+ this.assertText('ApplicationEngine');
+
+ this.assert.deepEqual(hooks, [
+ 'application - application',
+ 'engine - application'
+ ], 'the expected hooks were fired');
+ });
+ }
+});
diff --git a/packages/ember-glimmer/tests/integration/mount-test.js b/packages/ember-glimmer/tests/integration/mount-test.js
index 77672ab0688..70c6c05dad9 100644
--- a/packages/ember-glimmer/tests/integration/mount-test.js
+++ b/packages/ember-glimmer/tests/integration/mount-test.js
@@ -1,84 +1,81 @@
import { moduleFor, ApplicationTest, RenderingTest } from '../utils/test-case';
import { compile } from '../utils/helpers';
import Controller from 'ember-runtime/controllers/controller';
-import isEnabled from 'ember-metal/features';
import { set } from 'ember-metal/property_set';
import Engine from 'ember-application/system/engine';
import { getEngineParent } from 'ember-application/system/engine-parent';
import { getOwner } from 'container';
-if (isEnabled('ember-application-engines')) {
- moduleFor('{{mount}} assertions', class extends RenderingTest {
- ['@test it asserts that only a single param is passed']() {
- expectAssertion(() => {
- this.render('{{mount "chat" "foo"}}');
- }, /You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}./i);
- }
+moduleFor('{{mount}} assertions', class extends RenderingTest {
+ ['@test it asserts that only a single param is passed']() {
+ expectAssertion(() => {
+ this.render('{{mount "chat" "foo"}}');
+ }, /You can only pass a single argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}./i);
+ }
- ['@test it asserts that the engine name argument is quoted']() {
- expectAssertion(() => {
- this.render('{{mount chat}}');
- }, /The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}./i);
- }
+ ['@test it asserts that the engine name argument is quoted']() {
+ expectAssertion(() => {
+ this.render('{{mount chat}}');
+ }, /The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}./i);
+ }
- ['@test it asserts that the specified engine is registered']() {
- expectAssertion(() => {
- this.render('{{mount "chat"}}');
- }, /You used `{{mount 'chat'}}`, but the engine 'chat' can not be found./i);
- }
- });
+ ['@test it asserts that the specified engine is registered']() {
+ expectAssertion(() => {
+ this.render('{{mount "chat"}}');
+ }, /You used `{{mount 'chat'}}`, but the engine 'chat' can not be found./i);
+ }
+});
- moduleFor('{{mount}} test', class extends ApplicationTest {
- constructor() {
- super();
+moduleFor('{{mount}} test', class extends ApplicationTest {
+ constructor() {
+ super();
- let engineRegistrations = this.engineRegistrations = {};
+ let engineRegistrations = this.engineRegistrations = {};
- this.registerEngine('chat', Engine.extend({
- router: null,
+ this.registerEngine('chat', Engine.extend({
+ router: null,
- init() {
- this._super(...arguments);
+ init() {
+ this._super(...arguments);
- Object.keys(engineRegistrations).forEach(fullName => {
- this.register(fullName, engineRegistrations[fullName]);
- });
- }
- }));
+ Object.keys(engineRegistrations).forEach(fullName => {
+ this.register(fullName, engineRegistrations[fullName]);
+ });
+ }
+ }));
- this.registerTemplate('index', '{{mount "chat"}}');
- }
+ this.registerTemplate('index', '{{mount "chat"}}');
+ }
- ['@test it boots an engine, instantiates its application controller, and renders its application template'](assert) {
- this.engineRegistrations['template:application'] = compile('Chat here, {{username}}
', { moduleName: 'application' });
+ ['@test it boots an engine, instantiates its application controller, and renders its application template'](assert) {
+ this.engineRegistrations['template:application'] = compile('Chat here, {{username}}
', { moduleName: 'application' });
- let controller;
+ let controller;
- this.engineRegistrations['controller:application'] = Controller.extend({
- username: 'dgeb',
+ this.engineRegistrations['controller:application'] = Controller.extend({
+ username: 'dgeb',
- init() {
- this._super();
- controller = this;
- }
- });
+ init() {
+ this._super();
+ controller = this;
+ }
+ });
- return this.visit('/').then(() => {
- assert.ok(controller, 'engine\'s application controller has been instantiated');
+ return this.visit('/').then(() => {
+ assert.ok(controller, 'engine\'s application controller has been instantiated');
- let engineInstance = getOwner(controller);
- assert.strictEqual(getEngineParent(engineInstance), this.applicationInstance, 'engine instance has the application instance as its parent');
+ let engineInstance = getOwner(controller);
+ assert.strictEqual(getEngineParent(engineInstance), this.applicationInstance, 'engine instance has the application instance as its parent');
- this.assertComponentElement(this.firstChild, { content: 'Chat here, dgeb
' });
+ this.assertComponentElement(this.firstChild, { content: 'Chat here, dgeb
' });
- this.runTask(() => set(controller, 'username', 'chancancode'));
+ this.runTask(() => set(controller, 'username', 'chancancode'));
- this.assertComponentElement(this.firstChild, { content: 'Chat here, chancancode
' });
+ this.assertComponentElement(this.firstChild, { content: 'Chat here, chancancode
' });
- this.runTask(() => set(controller, 'username', 'dgeb'));
+ this.runTask(() => set(controller, 'username', 'dgeb'));
- this.assertComponentElement(this.firstChild, { content: 'Chat here, dgeb
' });
- });
- }
- });
-}
+ this.assertComponentElement(this.firstChild, { content: 'Chat here, dgeb
' });
+ });
+ }
+});
diff --git a/packages/ember-routing/lib/system/dsl.js b/packages/ember-routing/lib/system/dsl.js
index 1ac3b22202a..e1ee87cebc0 100644
--- a/packages/ember-routing/lib/system/dsl.js
+++ b/packages/ember-routing/lib/system/dsl.js
@@ -1,6 +1,5 @@
import { assert, deprecate } from 'ember-metal/debug';
import assign from 'ember-metal/assign';
-import isEnabled from 'ember-metal/features';
/**
@module ember
@@ -61,19 +60,17 @@ DSL.prototype = {
push(url, name, callback, serialize) {
let parts = name.split('.');
- if (isEnabled('ember-application-engines')) {
- if (this.options.engineInfo) {
- let localFullName = name.slice(this.options.engineInfo.fullName.length + 1);
- let routeInfo = assign({ localFullName }, this.options.engineInfo);
+ if (this.options.engineInfo) {
+ let localFullName = name.slice(this.options.engineInfo.fullName.length + 1);
+ let routeInfo = assign({ localFullName }, this.options.engineInfo);
- if (serialize) {
- routeInfo.serializeMethod = serialize;
- }
-
- this.options.addRouteForEngine(name, routeInfo);
- } else if (serialize) {
- throw new Error(`Defining a route serializer on route '${name}' outside an Engine is not allowed.`);
+ if (serialize) {
+ routeInfo.serializeMethod = serialize;
}
+
+ this.options.addRouteForEngine(name, routeInfo);
+ } else if (serialize) {
+ throw new Error(`Defining a route serializer on route '${name}' outside an Engine is not allowed.`);
}
if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { this.explicitIndex = true; }
@@ -142,65 +139,63 @@ DSL.map = function(callback) {
return dsl;
};
-if (isEnabled('ember-application-engines')) {
- let uuid = 0;
+let uuid = 0;
- DSL.prototype.mount = function(_name, _options) {
- let options = _options || {};
- let engineRouteMap = this.options.resolveRouteMap(_name);
- let name = _name;
+DSL.prototype.mount = function(_name, _options) {
+ let options = _options || {};
+ let engineRouteMap = this.options.resolveRouteMap(_name);
+ let name = _name;
- if (options.as) {
- name = options.as;
- }
+ if (options.as) {
+ name = options.as;
+ }
- var fullName = getFullName(this, name, options.resetNamespace);
+ var fullName = getFullName(this, name, options.resetNamespace);
- let engineInfo = {
- name: _name,
- instanceId: uuid++,
- mountPoint: fullName,
- fullName
- };
+ let engineInfo = {
+ name: _name,
+ instanceId: uuid++,
+ mountPoint: fullName,
+ fullName
+ };
- let path = options.path;
+ let path = options.path;
- if (typeof path !== 'string') {
- path = `/${name}`;
- }
+ if (typeof path !== 'string') {
+ path = `/${name}`;
+ }
- let callback;
- if (engineRouteMap) {
- let shouldResetEngineInfo = false;
- let oldEngineInfo = this.options.engineInfo;
- if (oldEngineInfo) {
- shouldResetEngineInfo = true;
- this.options.engineInfo = engineInfo;
- }
+ let callback;
+ if (engineRouteMap) {
+ let shouldResetEngineInfo = false;
+ let oldEngineInfo = this.options.engineInfo;
+ if (oldEngineInfo) {
+ shouldResetEngineInfo = true;
+ this.options.engineInfo = engineInfo;
+ }
- let optionsForChild = assign({ engineInfo }, this.options);
- let childDSL = new DSL(fullName, optionsForChild);
+ let optionsForChild = assign({ engineInfo }, this.options);
+ let childDSL = new DSL(fullName, optionsForChild);
- engineRouteMap.call(childDSL);
+ engineRouteMap.call(childDSL);
- callback = childDSL.generate();
+ callback = childDSL.generate();
- if (shouldResetEngineInfo) {
- this.options.engineInfo = oldEngineInfo;
- }
+ if (shouldResetEngineInfo) {
+ this.options.engineInfo = oldEngineInfo;
}
+ }
- if (this.enableLoadingSubstates) {
- let dummyErrorRoute = `/_unused_dummy_error_path_route_${name}/:error`;
- createRoute(this, `${name}_loading`, { resetNamespace: options.resetNamespace });
- createRoute(this, `${name}_error`, { resetNamespace: options.resetNamespace, path: dummyErrorRoute });
- }
+ if (this.enableLoadingSubstates) {
+ let dummyErrorRoute = `/_unused_dummy_error_path_route_${name}/:error`;
+ createRoute(this, `${name}_loading`, { resetNamespace: options.resetNamespace });
+ createRoute(this, `${name}_error`, { resetNamespace: options.resetNamespace, path: dummyErrorRoute });
+ }
- let localFullName = 'application';
- let routeInfo = assign({ localFullName }, engineInfo);
+ let localFullName = 'application';
+ let routeInfo = assign({ localFullName }, engineInfo);
- this.options.addRouteForEngine(fullName, routeInfo);
+ this.options.addRouteForEngine(fullName, routeInfo);
- this.push(path, fullName, callback);
- };
-}
+ this.push(path, fullName, callback);
+};
diff --git a/packages/ember-routing/lib/system/route.js b/packages/ember-routing/lib/system/route.js
index 816b40354ab..073c476fdf1 100644
--- a/packages/ember-routing/lib/system/route.js
+++ b/packages/ember-routing/lib/system/route.js
@@ -58,9 +58,7 @@ export function defaultSerialize(model, params) {
const DEFAULT_SERIALIZE = symbol('DEFAULT_SERIALIZE');
-if (isEnabled('ember-application-engines')) {
- defaultSerialize[DEFAULT_SERIALIZE] = true;
-}
+defaultSerialize[DEFAULT_SERIALIZE] = true;
export function hasDefaultSerialize(route) {
return !!route.serialize[DEFAULT_SERIALIZE];
@@ -394,11 +392,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, {
let state = transition ? transition.state : this.router.router.state;
let params = {};
- let fullName = name;
-
- if (isEnabled('ember-application-engines')) {
- fullName = getEngineRouteName(getOwner(this), name);
- }
+ let fullName = getEngineRouteName(getOwner(this), name);
assign(params, state.params[fullName]);
@@ -1070,7 +1064,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, {
*/
transitionTo(name, context) {
let router = this.router;
- return router.transitionTo(...arguments);
+ return router.transitionTo(...prefixRouteNameArg(this, arguments));
},
/**
@@ -1154,7 +1148,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, {
*/
replaceWith() {
let router = this.router;
- return router.replaceWith(...arguments);
+ return router.replaceWith(...prefixRouteNameArg(this, arguments));
},
/**
@@ -1797,7 +1791,18 @@ let Route = EmberObject.extend(ActionHandler, Evented, {
@return {Object} the model object
@public
*/
- modelFor(name) {
+ modelFor(_name) {
+ let name;
+ let owner = getOwner(this);
+
+ // Only change the route name when there is an active transition.
+ // Otherwise, use the passed in route name.
+ if (owner.routable && this.router && this.router.router.activeTransition) {
+ name = getEngineRouteName(owner, _name);
+ } else {
+ name = _name;
+ }
+
let route = getOwner(this).lookup(`route:${name}`);
let transition = this.router ? this.router.router.activeTransition : null;
@@ -2203,9 +2208,7 @@ function getQueryParamsFor(route, state) {
state.queryParamsFor = state.queryParamsFor || {};
let name = route.routeName;
- if (isEnabled('ember-application-engines')) {
- name = getEngineRouteName(getOwner(route), name);
- }
+ name = getEngineRouteName(getOwner(route), name);
if (state.queryParamsFor[name]) { return state.queryParamsFor[name]; }
@@ -2326,33 +2329,6 @@ function resemblesURL(str) {
return typeof str === 'string' && ( str === '' || str.charAt(0) === '/');
}
-if (isEnabled('ember-application-engines')) {
- Route.reopen({
- replaceWith(...args) {
- return this._super.apply(this, prefixRouteNameArg(this, args));
- },
-
- transitionTo(...args) {
- return this._super.apply(this, prefixRouteNameArg(this, args));
- },
-
- modelFor(_routeName, ...args) {
- let routeName;
- let owner = getOwner(this);
-
- if (owner.routable && this.router && this.router.router.activeTransition) {
- // only change the routeName when there is an active transition.
- // otherwise, we need the passed in route name.
- routeName = getEngineRouteName(owner, _routeName);
- } else {
- routeName = _routeName;
- }
-
- return this._super(routeName, ...args);
- }
- });
-}
-
function getEngineRouteName(engine, routeName) {
if (engine.routable) {
let prefix = engine.mountPoint;
diff --git a/packages/ember-routing/lib/system/router.js b/packages/ember-routing/lib/system/router.js
index 79b7deca54f..3f1d03564a2 100644
--- a/packages/ember-routing/lib/system/router.js
+++ b/packages/ember-routing/lib/system/router.js
@@ -1,7 +1,6 @@
import Logger from 'ember-console';
import { assert, info } from 'ember-metal/debug';
import EmberError from 'ember-metal/error';
-import isEnabled from 'ember-metal/features';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
import { defineProperty } from 'ember-metal/properties';
@@ -108,22 +107,20 @@ const EmberRouter = EmberObject.extend(Evented, {
enableLoadingSubstates: !!moduleBasedResolver
};
- if (isEnabled('ember-application-engines')) {
- let owner = getOwner(this);
- let router = this;
+ let owner = getOwner(this);
+ let router = this;
- options.enableLoadingSubstates = !!moduleBasedResolver;
+ options.enableLoadingSubstates = !!moduleBasedResolver;
- options.resolveRouteMap = function(name) {
- return owner._lookupFactory('route-map:' + name);
- };
+ options.resolveRouteMap = function(name) {
+ return owner._lookupFactory('route-map:' + name);
+ };
- options.addRouteForEngine = function(name, engineInfo) {
- if (!router._engineInfoByRoute[name]) {
- router._engineInfoByRoute[name] = engineInfo;
- }
- };
- }
+ options.addRouteForEngine = function(name, engineInfo) {
+ if (!router._engineInfoByRoute[name]) {
+ router._engineInfoByRoute[name] = engineInfo;
+ }
+ };
return new EmberRouterDSL(null, options);
},
@@ -135,11 +132,8 @@ const EmberRouter = EmberObject.extend(Evented, {
this._qpCache = new EmptyObject();
this._resetQueuedQueryParameterChanges();
this._handledErrors = dictionary(null);
-
- if (isEnabled('ember-application-engines')) {
- this._engineInstances = new EmptyObject();
- this._engineInfoByRoute = new EmptyObject();
- }
+ this._engineInstances = new EmptyObject();
+ this._engineInfoByRoute = new EmptyObject();
// avoid shaping issues with checks during `_setOutlets`
this.isDestroyed = false;
@@ -455,12 +449,10 @@ const EmberRouter = EmberObject.extend(Evented, {
},
willDestroy() {
- if (isEnabled('ember-application-engines')) {
- let instances = this._engineInstances;
- for (let name in instances) {
- for (let id in instances[name]) {
- run(instances[name][id], 'destroy');
- }
+ let instances = this._engineInstances;
+ for (let name in instances) {
+ for (let id in instances[name]) {
+ run(instances[name][id], 'destroy');
}
}
@@ -575,17 +567,13 @@ const EmberRouter = EmberObject.extend(Evented, {
return (name) => {
let routeName = name;
let routeOwner = owner;
- let engineInfo;
+ let engineInfo = this._engineInfoByRoute[routeName];
- if (isEnabled('ember-application-engines')) {
- engineInfo = this._engineInfoByRoute[routeName];
+ if (engineInfo) {
+ let engineInstance = this._getEngineInstance(engineInfo);
- if (engineInfo) {
- let engineInstance = this._getEngineInstance(engineInfo);
-
- routeOwner = engineInstance;
- routeName = engineInfo.localFullName;
- }
+ routeOwner = engineInstance;
+ routeName = engineInfo.localFullName;
}
let fullRouteName = 'route:' + routeName;
@@ -637,10 +625,7 @@ const EmberRouter = EmberObject.extend(Evented, {
let emberRouter = this;
router.getHandler = this._getHandlerFunction();
-
- if (isEnabled('ember-application-engines')) {
- router.getSerializer = this._getSerializerFunction();
- }
+ router.getSerializer = this._getSerializerFunction();
let doUpdateURL = function() {
location.setURL(lastURL);
@@ -894,6 +879,36 @@ const EmberRouter = EmberObject.extend(Evented, {
_clearHandledError(errorGuid) {
delete this._handledErrors[errorGuid];
+ },
+
+ _getEngineInstance({ name, instanceId, mountPoint }) {
+ let engineInstances = this._engineInstances;
+
+ if (!engineInstances[name]) {
+ engineInstances[name] = new EmptyObject();
+ }
+
+ let engineInstance = engineInstances[name][instanceId];
+
+ if (!engineInstance) {
+ let owner = getOwner(this);
+
+ assert(
+ 'You attempted to mount the engine \'' + name + '\' in your router map, but the engine can not be found.',
+ owner.hasRegistration(`engine:${name}`)
+ );
+
+ engineInstance = owner.buildChildEngineInstance(name, {
+ routable: true,
+ mountPoint
+ });
+
+ engineInstance.boot();
+
+ engineInstances[name][instanceId] = engineInstance;
+ }
+
+ return engineInstance;
}
});
@@ -1015,12 +1030,10 @@ function findChildRouteName(parentRoute, originatingChildRoute, name) {
let childName;
let originatingChildRouteName = originatingChildRoute.routeName;
- if (isEnabled('ember-application-engines')) {
- // The only time the originatingChildRoute's name should be 'application'
- // is if we're entering an engine
- if (originatingChildRouteName === 'application') {
- originatingChildRouteName = getOwner(originatingChildRoute).mountPoint;
- }
+ // The only time the originatingChildRoute's name should be 'application'
+ // is if we're entering an engine
+ if (originatingChildRouteName === 'application') {
+ originatingChildRouteName = getOwner(originatingChildRoute).mountPoint;
}
// First, try a named loading state of the route, e.g. 'foo_loading'
@@ -1360,38 +1373,4 @@ function representEmptyRoute(liveRoutes, defaultParentState, route) {
}
}
-if (isEnabled('ember-application-engines')) {
- EmberRouter.reopen({
- _getEngineInstance({ name, instanceId, mountPoint }) {
- let engineInstances = this._engineInstances;
-
- if (!engineInstances[name]) {
- engineInstances[name] = new EmptyObject();
- }
-
- let engineInstance = engineInstances[name][instanceId];
-
- if (!engineInstance) {
- let owner = getOwner(this);
-
- assert(
- 'You attempted to mount the engine \'' + name + '\' in your router map, but the engine can not be found.',
- owner.hasRegistration(`engine:${name}`)
- );
-
- engineInstance = owner.buildChildEngineInstance(name, {
- routable: true,
- mountPoint
- });
-
- engineInstance.boot();
-
- engineInstances[name][instanceId] = engineInstance;
- }
-
- return engineInstance;
- }
- });
-}
-
export default EmberRouter;
diff --git a/packages/ember-routing/tests/system/dsl_test.js b/packages/ember-routing/tests/system/dsl_test.js
index dfcb3fa2e4e..a1bb2a085fa 100644
--- a/packages/ember-routing/tests/system/dsl_test.js
+++ b/packages/ember-routing/tests/system/dsl_test.js
@@ -1,7 +1,6 @@
import EmberRouter from 'ember-routing/system/router';
import { setOwner } from 'container';
import buildOwner from 'container/tests/test-helpers/build-owner';
-import isEnabled from 'ember-metal/features';
let Router;
@@ -141,188 +140,186 @@ QUnit.test('should reset namespace of loading and error routes for routes with r
ok(!router.router.recognizer.names['blork.bleep_error'], 'nested reset error route was not added');
});
-if (isEnabled('ember-application-engines')) {
- QUnit.test('should throw an error when defining a route serializer outside an engine', function() {
- Router.map(function() {
- throws(() => {
- this.route('posts', { serialize: function() {} });
- }, /Defining a route serializer on route 'posts' outside an Engine is not allowed/);
- });
-
- Router.create()._initRouterJs();
+QUnit.test('should throw an error when defining a route serializer outside an engine', function() {
+ Router.map(function() {
+ throws(() => {
+ this.route('posts', { serialize: function() {} });
+ }, /Defining a route serializer on route 'posts' outside an Engine is not allowed/);
});
- QUnit.module('Ember Router DSL with engines', {
- setup,
- teardown
- });
+ Router.create()._initRouterJs();
+});
- QUnit.test('should allow mounting of engines', function(assert) {
- assert.expect(3);
+QUnit.module('Ember Router DSL with engines', {
+ setup,
+ teardown
+});
+
+QUnit.test('should allow mounting of engines', function(assert) {
+ assert.expect(3);
- Router = Router.map(function() {
- this.route('bleep', function() {
- this.route('bloop', function() {
- this.mount('chat');
- });
+ Router = Router.map(function() {
+ this.route('bleep', function() {
+ this.route('bloop', function() {
+ this.mount('chat');
});
});
+ });
- let engineInstance = buildOwner({
- routable: true
- });
+ let engineInstance = buildOwner({
+ routable: true
+ });
- let router = Router.create();
- setOwner(router, engineInstance);
- router._initRouterJs();
+ let router = Router.create();
+ setOwner(router, engineInstance);
+ router._initRouterJs();
- assert.ok(router.router.recognizer.names['bleep'], 'parent name was used as base of nested routes');
- assert.ok(router.router.recognizer.names['bleep.bloop'], 'parent name was used as base of nested routes');
- assert.ok(router.router.recognizer.names['bleep.bloop.chat'], 'parent name was used as base of mounted engine');
- });
+ assert.ok(router.router.recognizer.names['bleep'], 'parent name was used as base of nested routes');
+ assert.ok(router.router.recognizer.names['bleep.bloop'], 'parent name was used as base of nested routes');
+ assert.ok(router.router.recognizer.names['bleep.bloop.chat'], 'parent name was used as base of mounted engine');
+});
- QUnit.test('should allow mounting of engines at a custom path', function(assert) {
- assert.expect(1);
+QUnit.test('should allow mounting of engines at a custom path', function(assert) {
+ assert.expect(1);
- Router = Router.map(function() {
- this.route('bleep', function() {
- this.route('bloop', function() {
- this.mount('chat', { path: 'custom-chat' });
- });
+ Router = Router.map(function() {
+ this.route('bleep', function() {
+ this.route('bloop', function() {
+ this.mount('chat', { path: 'custom-chat' });
});
});
+ });
- let engineInstance = buildOwner({
- routable: true
- });
-
- let router = Router.create();
- setOwner(router, engineInstance);
- router._initRouterJs();
-
- assert.deepEqual(
- router.router.recognizer.names['bleep.bloop.chat']
- .segments
- .slice(1, 4)
- .map(s => s.string),
- ['bleep', 'bloop', 'custom-chat'],
- 'segments are properly associated with mounted engine');
+ let engineInstance = buildOwner({
+ routable: true
});
- QUnit.test('should allow aliasing of engine names with `as`', function(assert) {
- assert.expect(1);
+ let router = Router.create();
+ setOwner(router, engineInstance);
+ router._initRouterJs();
- Router = Router.map(function() {
- this.route('bleep', function() {
- this.route('bloop', function() {
- this.mount('chat', { as: 'blork' });
- });
- });
- });
+ assert.deepEqual(
+ router.router.recognizer.names['bleep.bloop.chat']
+ .segments
+ .slice(1, 4)
+ .map(s => s.string),
+ ['bleep', 'bloop', 'custom-chat'],
+ 'segments are properly associated with mounted engine');
+});
- let engineInstance = buildOwner({
- routable: true
+QUnit.test('should allow aliasing of engine names with `as`', function(assert) {
+ assert.expect(1);
+
+ Router = Router.map(function() {
+ this.route('bleep', function() {
+ this.route('bloop', function() {
+ this.mount('chat', { as: 'blork' });
+ });
});
+ });
- let router = Router.create();
- setOwner(router, engineInstance);
- router._initRouterJs();
-
- assert.deepEqual(
- router.router.recognizer.names['bleep.bloop.blork']
- .segments
- .slice(1, 4)
- .map(s => s.string),
- ['bleep', 'bloop', 'blork'],
- 'segments are properly associated with mounted engine with aliased name');
+ let engineInstance = buildOwner({
+ routable: true
});
- QUnit.test('should add loading and error routes to a mount if _isRouterMapResult is true', function() {
- Router.map(function() {
- this.mount('chat');
- });
+ let router = Router.create();
+ setOwner(router, engineInstance);
+ router._initRouterJs();
- let engineInstance = buildOwner({
- routable: true
- });
+ assert.deepEqual(
+ router.router.recognizer.names['bleep.bloop.blork']
+ .segments
+ .slice(1, 4)
+ .map(s => s.string),
+ ['bleep', 'bloop', 'blork'],
+ 'segments are properly associated with mounted engine with aliased name');
+});
- let router = Router.create({
- _hasModuleBasedResolver() { return true; }
- });
- setOwner(router, engineInstance);
- router._initRouterJs();
+QUnit.test('should add loading and error routes to a mount if _isRouterMapResult is true', function() {
+ Router.map(function() {
+ this.mount('chat');
+ });
- ok(router.router.recognizer.names['chat'], 'main route was created');
- ok(router.router.recognizer.names['chat_loading'], 'loading route was added');
- ok(router.router.recognizer.names['chat_error'], 'error route was added');
+ let engineInstance = buildOwner({
+ routable: true
});
- QUnit.test('should add loading and error routes to a mount alias if _isRouterMapResult is true', function() {
- Router.map(function() {
- this.mount('chat', { as: 'shoutbox' });
- });
+ let router = Router.create({
+ _hasModuleBasedResolver() { return true; }
+ });
+ setOwner(router, engineInstance);
+ router._initRouterJs();
- let engineInstance = buildOwner({
- routable: true
- });
+ ok(router.router.recognizer.names['chat'], 'main route was created');
+ ok(router.router.recognizer.names['chat_loading'], 'loading route was added');
+ ok(router.router.recognizer.names['chat_error'], 'error route was added');
+});
- let router = Router.create({
- _hasModuleBasedResolver() { return true; }
- });
- setOwner(router, engineInstance);
- router._initRouterJs();
+QUnit.test('should add loading and error routes to a mount alias if _isRouterMapResult is true', function() {
+ Router.map(function() {
+ this.mount('chat', { as: 'shoutbox' });
+ });
- ok(router.router.recognizer.names['shoutbox'], 'main route was created');
- ok(router.router.recognizer.names['shoutbox_loading'], 'loading route was added');
- ok(router.router.recognizer.names['shoutbox_error'], 'error route was added');
+ let engineInstance = buildOwner({
+ routable: true
});
- QUnit.test('should not add loading and error routes to a mount if _isRouterMapResult is false', function() {
- Router.map(function() {
- this.mount('chat');
- });
+ let router = Router.create({
+ _hasModuleBasedResolver() { return true; }
+ });
+ setOwner(router, engineInstance);
+ router._initRouterJs();
- let engineInstance = buildOwner({
- routable: true
- });
+ ok(router.router.recognizer.names['shoutbox'], 'main route was created');
+ ok(router.router.recognizer.names['shoutbox_loading'], 'loading route was added');
+ ok(router.router.recognizer.names['shoutbox_error'], 'error route was added');
+});
- let router = Router.create();
- setOwner(router, engineInstance);
- router._initRouterJs(false);
+QUnit.test('should not add loading and error routes to a mount if _isRouterMapResult is false', function() {
+ Router.map(function() {
+ this.mount('chat');
+ });
- ok(router.router.recognizer.names['chat'], 'main route was created');
- ok(!router.router.recognizer.names['chat_loading'], 'loading route was not added');
- ok(!router.router.recognizer.names['chat_error'], 'error route was not added');
+ let engineInstance = buildOwner({
+ routable: true
});
- QUnit.test('should reset namespace of loading and error routes for mounts with resetNamespace', function() {
- Router.map(function() {
- this.route('news', function() {
- this.mount('chat');
- this.mount('blog', { resetNamespace: true });
- });
- });
+ let router = Router.create();
+ setOwner(router, engineInstance);
+ router._initRouterJs(false);
- let engineInstance = buildOwner({
- routable: true
- });
+ ok(router.router.recognizer.names['chat'], 'main route was created');
+ ok(!router.router.recognizer.names['chat_loading'], 'loading route was not added');
+ ok(!router.router.recognizer.names['chat_error'], 'error route was not added');
+});
- let router = Router.create({
- _hasModuleBasedResolver() { return true; }
+QUnit.test('should reset namespace of loading and error routes for mounts with resetNamespace', function() {
+ Router.map(function() {
+ this.route('news', function() {
+ this.mount('chat');
+ this.mount('blog', { resetNamespace: true });
});
- setOwner(router, engineInstance);
- router._initRouterJs();
-
- ok(router.router.recognizer.names['news.chat'], 'nested route was created');
- ok(router.router.recognizer.names['news.chat_loading'], 'nested loading route was added');
- ok(router.router.recognizer.names['news.chat_error'], 'nested error route was added');
+ });
- ok(router.router.recognizer.names['blog'], 'reset route was created');
- ok(router.router.recognizer.names['blog_loading'], 'reset loading route was added');
- ok(router.router.recognizer.names['blog_error'], 'reset error route was added');
+ let engineInstance = buildOwner({
+ routable: true
+ });
- ok(!router.router.recognizer.names['news.blog'], 'nested reset route was not created');
- ok(!router.router.recognizer.names['news.blog_loading'], 'nested reset loading route was not added');
- ok(!router.router.recognizer.names['news.blog_error'], 'nested reset error route was not added');
+ let router = Router.create({
+ _hasModuleBasedResolver() { return true; }
});
-}
+ setOwner(router, engineInstance);
+ router._initRouterJs();
+
+ ok(router.router.recognizer.names['news.chat'], 'nested route was created');
+ ok(router.router.recognizer.names['news.chat_loading'], 'nested loading route was added');
+ ok(router.router.recognizer.names['news.chat_error'], 'nested error route was added');
+
+ ok(router.router.recognizer.names['blog'], 'reset route was created');
+ ok(router.router.recognizer.names['blog_loading'], 'reset loading route was added');
+ ok(router.router.recognizer.names['blog_error'], 'reset error route was added');
+
+ ok(!router.router.recognizer.names['news.blog'], 'nested reset route was not created');
+ ok(!router.router.recognizer.names['news.blog_loading'], 'nested reset loading route was not added');
+ ok(!router.router.recognizer.names['news.blog_error'], 'nested reset error route was not added');
+});
diff --git a/packages/ember-routing/tests/system/route_test.js b/packages/ember-routing/tests/system/route_test.js
index 90f5a1a2e30..c66a9367f1c 100644
--- a/packages/ember-routing/tests/system/route_test.js
+++ b/packages/ember-routing/tests/system/route_test.js
@@ -5,7 +5,6 @@ import EmberRoute from 'ember-routing/system/route';
import inject from 'ember-runtime/inject';
import buildOwner from 'container/tests/test-helpers/build-owner';
import { setOwner } from 'container';
-import isEnabled from 'ember-metal/features';
let route, routeOne, routeTwo, lookupHash;
@@ -323,93 +322,91 @@ QUnit.test('services can be injected into routes', function() {
equal(authService, appRoute.get('authService'), 'service.auth is injected');
});
-if (isEnabled('ember-application-engines')) {
- QUnit.module('Ember.Route with engines');
-
- QUnit.test('paramsFor considers an engine\'s mountPoint', function(assert) {
- expect(2);
-
- let router = {
- _deserializeQueryParams() {},
- router: {
- state: {
- handlerInfos: [
- { name: 'posts' }
- ],
- params: {
- 'foo.bar': { a: 'b' },
- 'foo.bar.posts': { c: 'd' }
- }
+QUnit.module('Ember.Route with engines');
+
+QUnit.test('paramsFor considers an engine\'s mountPoint', function(assert) {
+ expect(2);
+
+ let router = {
+ _deserializeQueryParams() {},
+ router: {
+ state: {
+ handlerInfos: [
+ { name: 'posts' }
+ ],
+ params: {
+ 'foo.bar': { a: 'b' },
+ 'foo.bar.posts': { c: 'd' }
}
}
- };
+ }
+ };
- let engineInstance = buildOwner({
- routable: true,
+ let engineInstance = buildOwner({
+ routable: true,
- mountPoint: 'foo.bar',
+ mountPoint: 'foo.bar',
- lookup(name) {
- if (name === 'route:posts') {
- return postsRoute;
- } else if (name === 'route:application') {
- return applicationRoute;
- }
+ lookup(name) {
+ if (name === 'route:posts') {
+ return postsRoute;
+ } else if (name === 'route:application') {
+ return applicationRoute;
}
- });
+ }
+ });
- let applicationRoute = EmberRoute.create({ router, routeName: 'application' });
- let postsRoute = EmberRoute.create({ router, routeName: 'posts' });
- let route = EmberRoute.create({ router });
+ let applicationRoute = EmberRoute.create({ router, routeName: 'application' });
+ let postsRoute = EmberRoute.create({ router, routeName: 'posts' });
+ let route = EmberRoute.create({ router });
- setOwner(applicationRoute, engineInstance);
- setOwner(postsRoute, engineInstance);
- setOwner(route, engineInstance);
+ setOwner(applicationRoute, engineInstance);
+ setOwner(postsRoute, engineInstance);
+ setOwner(route, engineInstance);
- assert.deepEqual(route.paramsFor('application'), { a: 'b' }, 'params match for root `application` route in engine');
- assert.deepEqual(route.paramsFor('posts'), { c: 'd' }, 'params match for `posts` route in engine');
- });
+ assert.deepEqual(route.paramsFor('application'), { a: 'b' }, 'params match for root `application` route in engine');
+ assert.deepEqual(route.paramsFor('posts'), { c: 'd' }, 'params match for `posts` route in engine');
+});
- QUnit.test('modelFor considers an engine\'s mountPoint', function() {
- expect(2);
+QUnit.test('modelFor considers an engine\'s mountPoint', function() {
+ expect(2);
- let applicationModel = { id: '1' };
- let postsModel = { id: '2' };
+ let applicationModel = { id: '1' };
+ let postsModel = { id: '2' };
- let router = {
- router: {
- activeTransition: {
- resolvedModels: {
- 'foo.bar': applicationModel,
- 'foo.bar.posts': postsModel
- }
+ let router = {
+ router: {
+ activeTransition: {
+ resolvedModels: {
+ 'foo.bar': applicationModel,
+ 'foo.bar.posts': postsModel
}
}
- };
+ }
+ };
- let engineInstance = buildOwner({
- routable: true,
+ let engineInstance = buildOwner({
+ routable: true,
- mountPoint: 'foo.bar',
+ mountPoint: 'foo.bar',
- lookup(name) {
- if (name === 'route:posts') {
- return postsRoute;
- } else if (name === 'route:application') {
- return applicationRoute;
- }
+ lookup(name) {
+ if (name === 'route:posts') {
+ return postsRoute;
+ } else if (name === 'route:application') {
+ return applicationRoute;
}
- });
+ }
+ });
- let applicationRoute = EmberRoute.create({ router, routeName: 'application' });
- let postsRoute = EmberRoute.create({ router, routeName: 'posts' });
- let route = EmberRoute.create({ router });
+ let applicationRoute = EmberRoute.create({ router, routeName: 'application' });
+ let postsRoute = EmberRoute.create({ router, routeName: 'posts' });
+ let route = EmberRoute.create({ router });
- setOwner(applicationRoute, engineInstance);
- setOwner(postsRoute, engineInstance);
- setOwner(route, engineInstance);
+ setOwner(applicationRoute, engineInstance);
+ setOwner(postsRoute, engineInstance);
+ setOwner(route, engineInstance);
- strictEqual(route.modelFor('application'), applicationModel);
- strictEqual(route.modelFor('posts'), postsModel);
- });
-}
+ strictEqual(route.modelFor('application'), applicationModel);
+ strictEqual(route.modelFor('posts'), postsModel);
+});
diff --git a/packages/ember/tests/routing/basic_test.js b/packages/ember/tests/routing/basic_test.js
index 30770d635e2..8c404a5b596 100644
--- a/packages/ember/tests/routing/basic_test.js
+++ b/packages/ember/tests/routing/basic_test.js
@@ -4,7 +4,6 @@ import Route from 'ember-routing/system/route';
import run from 'ember-metal/run_loop';
import RSVP from 'ember-runtime/ext/rsvp';
import EmberObject from 'ember-runtime/system/object';
-import isEnabled from 'ember-metal/features';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
import { computed } from 'ember-metal/computed';
@@ -3688,101 +3687,99 @@ QUnit.test('Exception if outlet name is undefined in render and disconnectOutlet
}, /You passed undefined as the outlet name/);
});
-if (isEnabled('ember-application-engines')) {
- QUnit.test('Route serializers work for Engines', function() {
- expect(2);
+QUnit.test('Route serializers work for Engines', function() {
+ expect(2);
- // Register engine
- let BlogEngine = Engine.extend();
- registry.register('engine:blog', BlogEngine);
+ // Register engine
+ let BlogEngine = Engine.extend();
+ registry.register('engine:blog', BlogEngine);
- // Register engine route map
- let postSerialize = function(params) {
- ok(true, 'serialize hook runs');
- return {
- post_id: params.id
- };
- };
- let BlogMap = function() {
- this.route('post', { path: '/post/:post_id', serialize: postSerialize });
+ // Register engine route map
+ let postSerialize = function(params) {
+ ok(true, 'serialize hook runs');
+ return {
+ post_id: params.id
};
- registry.register('route-map:blog', BlogMap);
+ };
+ let BlogMap = function() {
+ this.route('post', { path: '/post/:post_id', serialize: postSerialize });
+ };
+ registry.register('route-map:blog', BlogMap);
- Router.map(function() {
- this.mount('blog');
- });
+ Router.map(function() {
+ this.mount('blog');
+ });
- bootApplication();
+ bootApplication();
- equal(router.router.generate('blog.post', { id: '13' }), '/blog/post/13', 'url is generated properly');
- });
+ equal(router.router.generate('blog.post', { id: '13' }), '/blog/post/13', 'url is generated properly');
+});
- QUnit.test('Defining a Route#serialize method in an Engine throws an error', function() {
- expect(1);
+QUnit.test('Defining a Route#serialize method in an Engine throws an error', function() {
+ expect(1);
- // Register engine
- let BlogEngine = Engine.extend();
- registry.register('engine:blog', BlogEngine);
+ // Register engine
+ let BlogEngine = Engine.extend();
+ registry.register('engine:blog', BlogEngine);
- // Register engine route map
- let BlogMap = function() {
- this.route('post');
- };
- registry.register('route-map:blog', BlogMap);
+ // Register engine route map
+ let BlogMap = function() {
+ this.route('post');
+ };
+ registry.register('route-map:blog', BlogMap);
- Router.map(function() {
- this.mount('blog');
- });
+ Router.map(function() {
+ this.mount('blog');
+ });
- bootApplication();
+ bootApplication();
- let PostRoute = Route.extend({ serialize() {} });
- container.lookup('engine:blog').register('route:post', PostRoute);
+ let PostRoute = Route.extend({ serialize() {} });
+ container.lookup('engine:blog').register('route:post', PostRoute);
- throws(() => router.transitionTo('blog.post'), /Defining a custom serialize method on an Engine route is not supported/);
- });
+ throws(() => router.transitionTo('blog.post'), /Defining a custom serialize method on an Engine route is not supported/);
+});
- QUnit.test('App.destroy does not leave undestroyed views after clearing engines', function() {
- expect(4);
+QUnit.test('App.destroy does not leave undestroyed views after clearing engines', function() {
+ expect(4);
- let engineInstance;
- // Register engine
- let BlogEngine = Engine.extend();
- registry.register('engine:blog', BlogEngine);
- let EngineIndexRoute = Route.extend({
- init() {
- this._super(...arguments);
- engineInstance = getOwner(this);
- }
- });
+ let engineInstance;
+ // Register engine
+ let BlogEngine = Engine.extend();
+ registry.register('engine:blog', BlogEngine);
+ let EngineIndexRoute = Route.extend({
+ init() {
+ this._super(...arguments);
+ engineInstance = getOwner(this);
+ }
+ });
- // Register engine route map
- let BlogMap = function() {
- this.route('post');
- };
- registry.register('route-map:blog', BlogMap);
+ // Register engine route map
+ let BlogMap = function() {
+ this.route('post');
+ };
+ registry.register('route-map:blog', BlogMap);
- Router.map(function() {
- this.mount('blog');
- });
+ Router.map(function() {
+ this.mount('blog');
+ });
- bootApplication();
+ bootApplication();
- let engine = container.lookup('engine:blog');
- engine.register('route:index', EngineIndexRoute);
- engine.register('template:index', compile('Engine Post!'));
+ let engine = container.lookup('engine:blog');
+ engine.register('route:index', EngineIndexRoute);
+ engine.register('template:index', compile('Engine Post!'));
- handleURL('/blog');
+ handleURL('/blog');
- let route = engineInstance.lookup('route:index');
+ let route = engineInstance.lookup('route:index');
- run(router, 'destroy');
- equal(router._toplevelView, null, 'the toplevelView was cleared');
+ run(router, 'destroy');
+ equal(router._toplevelView, null, 'the toplevelView was cleared');
- run(route, 'destroy');
- equal(router._toplevelView, null, 'the toplevelView was not reinitialized');
+ run(route, 'destroy');
+ equal(router._toplevelView, null, 'the toplevelView was not reinitialized');
- run(App, 'destroy');
- equal(router._toplevelView, null, 'the toplevelView was not reinitialized');
- });
-}
+ run(App, 'destroy');
+ equal(router._toplevelView, null, 'the toplevelView was not reinitialized');
+});
diff --git a/packages/ember/tests/routing/substates_test.js b/packages/ember/tests/routing/substates_test.js
index f042716d223..179f5b0981e 100644
--- a/packages/ember/tests/routing/substates_test.js
+++ b/packages/ember/tests/routing/substates_test.js
@@ -9,7 +9,6 @@ import jQuery from 'ember-views/system/jquery';
import NoneLocation from 'ember-routing/location/none_location';
import DefaultResolver from 'ember-application/system/resolver';
import { setTemplates, setTemplate } from 'ember-glimmer';
-import isEnabled from 'ember-metal/features';
let Router, App, templates, router, container, registry, counter;
@@ -1052,109 +1051,107 @@ QUnit.test('Rejected promises returned from ApplicationRoute transition into top
equal(jQuery('#app', '#qunit-fixture').text(), 'INDEX');
});
-if (isEnabled('ember-application-engines')) {
- QUnit.test('Slow Promise from an Engine application route enters the mounts loading state', function() {
- expect(1);
+QUnit.test('Slow Promise from an Engine application route enters the mounts loading state', function() {
+ expect(1);
- templates['news/blog_loading'] = 'BLOG LOADING';
+ templates['news/blog_loading'] = 'BLOG LOADING';
- // Register engine
- let BlogEngine = Engine.extend();
- registry.register('engine:blog', BlogEngine);
+ // Register engine
+ let BlogEngine = Engine.extend();
+ registry.register('engine:blog', BlogEngine);
- // Register engine route map
- let BlogMap = function() {};
- registry.register('route-map:blog', BlogMap);
+ // Register engine route map
+ let BlogMap = function() {};
+ registry.register('route-map:blog', BlogMap);
- Router.map(function() {
- this.route('news', function() {
- this.mount('blog');
- });
+ Router.map(function() {
+ this.route('news', function() {
+ this.mount('blog');
});
+ });
- let deferred = RSVP.defer();
- let BlogRoute = Route.extend({
- model() {
- return deferred.promise;
- }
- });
+ let deferred = RSVP.defer();
+ let BlogRoute = Route.extend({
+ model() {
+ return deferred.promise;
+ }
+ });
- var blog = container.lookup('engine:blog');
- blog.register('route:application', BlogRoute);
+ var blog = container.lookup('engine:blog');
+ blog.register('route:application', BlogRoute);
- bootApplication('/news/blog');
+ bootApplication('/news/blog');
- equal(jQuery('#app', '#qunit-fixture').text(), 'BLOG LOADING', 'news/blog_loading was entered');
+ equal(jQuery('#app', '#qunit-fixture').text(), 'BLOG LOADING', 'news/blog_loading was entered');
- run(deferred, 'resolve');
- });
+ run(deferred, 'resolve');
+});
- QUnit.test('Rejected Promise from an Engine application route enters the mounts error state', function() {
- expect(1);
+QUnit.test('Rejected Promise from an Engine application route enters the mounts error state', function() {
+ expect(1);
- templates['news/blog_error'] = 'BLOG ERROR';
+ templates['news/blog_error'] = 'BLOG ERROR';
- // Register engine
- let BlogEngine = Engine.extend();
- registry.register('engine:blog', BlogEngine);
+ // Register engine
+ let BlogEngine = Engine.extend();
+ registry.register('engine:blog', BlogEngine);
- // Register engine route map
- let BlogMap = function() {};
- registry.register('route-map:blog', BlogMap);
+ // Register engine route map
+ let BlogMap = function() {};
+ registry.register('route-map:blog', BlogMap);
- Router.map(function() {
- this.route('news', function() {
- this.mount('blog');
- });
+ Router.map(function() {
+ this.route('news', function() {
+ this.mount('blog');
});
+ });
- let BlogRoute = Route.extend({
- model() {
- return RSVP.Promise.reject();
- }
- });
+ let BlogRoute = Route.extend({
+ model() {
+ return RSVP.Promise.reject();
+ }
+ });
- var blog = container.lookup('engine:blog');
- blog.register('route:application', BlogRoute);
+ var blog = container.lookup('engine:blog');
+ blog.register('route:application', BlogRoute);
- bootApplication('/news/blog');
+ bootApplication('/news/blog');
- equal(jQuery('#app', '#qunit-fixture').text(), 'BLOG ERROR', 'news/blog_loading was entered');
- });
+ equal(jQuery('#app', '#qunit-fixture').text(), 'BLOG ERROR', 'news/blog_loading was entered');
+});
- QUnit.test('Slow Promise from an Engine application route enters the mounts loading state with resetNamespace', function() {
- expect(1);
+QUnit.test('Slow Promise from an Engine application route enters the mounts loading state with resetNamespace', function() {
+ expect(1);
- templates['blog_loading'] = 'BLOG LOADING';
+ templates['blog_loading'] = 'BLOG LOADING';
- // Register engine
- let BlogEngine = Engine.extend();
- registry.register('engine:blog', BlogEngine);
+ // Register engine
+ let BlogEngine = Engine.extend();
+ registry.register('engine:blog', BlogEngine);
- // Register engine route map
- let BlogMap = function() {};
- registry.register('route-map:blog', BlogMap);
+ // Register engine route map
+ let BlogMap = function() {};
+ registry.register('route-map:blog', BlogMap);
- Router.map(function() {
- this.route('news', function() {
- this.mount('blog', { resetNamespace: true });
- });
+ Router.map(function() {
+ this.route('news', function() {
+ this.mount('blog', { resetNamespace: true });
});
+ });
- let deferred = RSVP.defer();
- let BlogRoute = Route.extend({
- model() {
- return deferred.promise;
- }
- });
+ let deferred = RSVP.defer();
+ let BlogRoute = Route.extend({
+ model() {
+ return deferred.promise;
+ }
+ });
- var blog = container.lookup('engine:blog');
- blog.register('route:application', BlogRoute);
+ var blog = container.lookup('engine:blog');
+ blog.register('route:application', BlogRoute);
- bootApplication('/news/blog');
+ bootApplication('/news/blog');
- equal(jQuery('#app', '#qunit-fixture').text(), 'BLOG LOADING', 'news/blog_loading was entered');
+ equal(jQuery('#app', '#qunit-fixture').text(), 'BLOG LOADING', 'news/blog_loading was entered');
- run(deferred, 'resolve');
- });
-}
+ run(deferred, 'resolve');
+});