ember-source 4.4.0-alpha.1 → 4.4.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js +4 -4
  2. package/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js +2 -2
  3. package/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +2 -2
  4. package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +2 -2
  5. package/blueprints/component/index.js +2 -2
  6. package/blueprints/component-class/index.js +2 -2
  7. package/blueprints/component-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +4 -4
  8. package/blueprints/component-test/mocha-files/__root__/__testType__/__path__/__test__.js +7 -5
  9. package/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +4 -4
  10. package/blueprints/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +4 -4
  11. package/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +4 -4
  12. package/blueprints/controller/files/__root__/__path__/__name__.js +1 -2
  13. package/blueprints/controller-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
  14. package/blueprints/controller-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
  15. package/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
  16. package/blueprints/controller-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
  17. package/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
  18. package/blueprints/helper/files/__root__/__collection__/__name__.js +1 -1
  19. package/blueprints/helper/mu-files/__root__/__collection__/__name__.js +1 -1
  20. package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +3 -3
  21. package/blueprints/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +6 -4
  22. package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -2
  23. package/blueprints/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +2 -2
  24. package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -2
  25. package/blueprints/initializer/files/__root__/initializers/__name__.js +2 -3
  26. package/blueprints/initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +6 -7
  27. package/blueprints/initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +5 -5
  28. package/blueprints/initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +3 -4
  29. package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js +2 -3
  30. package/blueprints/instance-initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +5 -5
  31. package/blueprints/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +5 -5
  32. package/blueprints/instance-initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +2 -2
  33. package/blueprints/mixin/files/__root__/mixins/__name__.js +1 -2
  34. package/blueprints/mixin-test/mocha-files/__root__/__testType__/__name__-test.js +2 -2
  35. package/blueprints/mixin-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +2 -2
  36. package/blueprints/mixin-test/qunit-files/__root__/__testType__/__name__-test.js +1 -1
  37. package/blueprints/mixin-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +1 -1
  38. package/blueprints/route/files/__root__/__path__/__name__.js +2 -2
  39. package/blueprints/route-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
  40. package/blueprints/route-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
  41. package/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
  42. package/blueprints/route-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
  43. package/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
  44. package/blueprints/service/files/__root__/__path__/__name__.js +1 -2
  45. package/blueprints/service-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
  46. package/blueprints/service-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
  47. package/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
  48. package/blueprints/service-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
  49. package/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
  50. package/blueprints/util-test/mocha-files/__root__/__testType__/__name__-test.js +2 -2
  51. package/blueprints/util-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +2 -2
  52. package/blueprints/util-test/qunit-files/__root__/__testType__/__name__-test.js +1 -1
  53. package/blueprints/util-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +2 -3
  54. package/build-metadata.json +3 -3
  55. package/dist/dependencies/router_js.js +1 -1
  56. package/dist/ember-template-compiler.js +10 -140
  57. package/dist/ember-template-compiler.map +1 -1
  58. package/dist/ember-testing.js +3 -1
  59. package/dist/ember-testing.map +1 -1
  60. package/dist/ember.debug.js +152 -189
  61. package/dist/ember.debug.map +1 -1
  62. package/dist/header/license.js +1 -1
  63. package/dist/packages/@ember/-internals/container/index.js +3 -3
  64. package/dist/packages/@ember/-internals/glimmer/index.js +18 -25
  65. package/dist/packages/@ember/-internals/metal/index.js +14 -16
  66. package/dist/packages/@ember/-internals/routing/lib/services/router.js +2 -0
  67. package/dist/packages/@ember/-internals/routing/lib/services/routing.js +2 -0
  68. package/dist/packages/@ember/-internals/routing/lib/system/generate_controller.js +3 -1
  69. package/dist/packages/@ember/-internals/routing/lib/system/route.js +14 -6
  70. package/dist/packages/@ember/-internals/routing/lib/system/router.js +5 -13
  71. package/dist/packages/@ember/-internals/routing/lib/utils.js +2 -1
  72. package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +29 -29
  73. package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +51 -50
  74. package/dist/packages/@ember/-internals/utils/index.js +1 -1
  75. package/dist/packages/@ember/application/instance.js +3 -3
  76. package/dist/packages/@ember/canary-features/index.js +0 -10
  77. package/dist/packages/@ember/debug/lib/capture-render-tree.js +2 -0
  78. package/dist/packages/ember/index.js +3 -14
  79. package/dist/packages/ember/version.js +1 -1
  80. package/docs/data.json +173 -189
  81. package/package.json +3 -3
@@ -5,5 +5,5 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 4.4.0-alpha.1
8
+ * @version 4.4.0-alpha.2
9
9
  */
@@ -187,8 +187,6 @@ class Container {
187
187
  @public
188
188
  @method factoryFor
189
189
  @param {String} fullName
190
- @param {Object} [options]
191
- @param {String} [options.source] The fullname of the request source (used for local lookup)
192
190
  @return {any}
193
191
  */
194
192
 
@@ -199,7 +197,9 @@ class Container {
199
197
  }
200
198
 
201
199
  let normalizedName = this.registry.normalize(fullName);
202
- assert('fullName must be a proper full name', this.registry.isValidFullName(normalizedName));
200
+ assert('fullName must be a proper full name', this.registry.isValidFullName(normalizedName)); // TODO: This needs to return a Factory to be compatible with Owner.
201
+ // We should correctly the types so that this cast is not necessary.
202
+
203
203
  return factoryFor(this, normalizedName, fullName);
204
204
  }
205
205
 
@@ -9,8 +9,9 @@ import { untrack, consumeTag, createCache, getValue, tagFor, beginUntrackFrame,
9
9
  import { tracked, get, PROPERTY_DID_CHANGE, tagForObject, objectAt, tagForProperty, set, _getProp, _setProp } from '@ember/-internals/metal';
10
10
  import { action } from '@ember/object';
11
11
  import { hasDOM } from '@ember/-internals/browser-environment';
12
- import { isSimpleClick, clearElementView, clearViewElement, getViewElement, MUTABLE_CELL, addChildView, setElementView, setViewElement, ActionSupport, ChildViewsSupport, ClassNamesSupport, CoreView, ViewMixin, ViewStateSupport, constructStyleDeprecationMessage, ActionManager, getViewId } from '@ember/-internals/views';
12
+ import { isSimpleClick, clearElementView, clearViewElement, getViewElement, MUTABLE_CELL, addChildView, setElementView, setViewElement, ActionSupport, ChildViewsSupport, ClassNamesSupport, CoreView, EventDispatcher, ViewMixin, ViewStateSupport, constructStyleDeprecationMessage, ActionManager, getViewId } from '@ember/-internals/views';
13
13
  import { getEngineParent } from '@ember/engine';
14
+ import EngineInstance from '@ember/engine/instance';
14
15
  import { flaggedInstrument, _instrumentStart } from '@ember/instrumentation';
15
16
  import { service } from '@ember/service';
16
17
  import { DEBUG } from '@glimmer/env';
@@ -1099,11 +1100,13 @@ class LinkTo extends InternalComponent {
1099
1100
  }
1100
1101
 
1101
1102
  get isEngine() {
1102
- return getEngineParent(this.owner) !== undefined;
1103
+ let owner = this.owner;
1104
+ return owner instanceof EngineInstance && getEngineParent(owner) !== undefined;
1103
1105
  }
1104
1106
 
1105
1107
  get engineMountPoint() {
1106
- return this.owner.mountPoint;
1108
+ let owner = this.owner;
1109
+ return owner instanceof EngineInstance ? owner.mountPoint : undefined;
1107
1110
  }
1108
1111
 
1109
1112
  classFor(state) {
@@ -3165,6 +3168,7 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
3165
3168
 
3166
3169
  if (owner.lookup('-environment:main').isInteractive) {
3167
3170
  this.__dispatcher = owner.lookup('event_dispatcher:main');
3171
+ assert('Expected dispatcher to be an EventDispatcher', this.__dispatcher instanceof EventDispatcher);
3168
3172
  } else {
3169
3173
  // In FastBoot we have no EventDispatcher. Set to null to not try again to look it up.
3170
3174
  this.__dispatcher = null;
@@ -3787,11 +3791,9 @@ class OutletComponentManager {
3787
3791
  let currentOwner = valueForRef(currentStateRef).render.owner;
3788
3792
 
3789
3793
  if (parentOwner && parentOwner !== currentOwner) {
3790
- let engine = currentOwner;
3791
- assert('invalid engine: missing mountPoint', typeof currentOwner.mountPoint === 'string');
3792
- assert('invalid engine: missing routable', currentOwner.routable === true);
3793
- let mountPoint = engine.mountPoint;
3794
- state.engine = engine;
3794
+ assert('Expected currentOwner to be an EngineInstance', currentOwner instanceof EngineInstance);
3795
+ let mountPoint = currentOwner.mountPoint;
3796
+ state.engine = currentOwner;
3795
3797
  state.engineBucket = {
3796
3798
  mountPoint
3797
3799
  };
@@ -4575,7 +4577,7 @@ var disallowDynamicResolution = internalHelper(({
4575
4577
  assert('[BUG] expecting a string literal for the `original` argument', typeof original === 'string');
4576
4578
  return createComputeRef(() => {
4577
4579
  let nameOrValue = valueForRef(nameOrValueRef);
4578
- assert(`Passing a dynamic string to the \`(${type})\` keyword is disallowed. ` + `(You specified \`(${type} ${original})\` and \`${original}\` evaluated into "${nameOrValue}".) ` + `This ensures we can statically analyze the template and determine which ${type}s are used. ` + `If the ${type} name is always the same, use a string literal instead, i.e. \`(${type} "${nameOrValue}")\`. ` + `Otherwise, import the ${type}s into JavaScript and pass them to the ${type} keyword. ` + 'See https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#4-no-dynamic-resolution for details. ' + loc, typeof nameOrValue !== 'string');
4580
+ assert(`Passing a dynamic string to the \`(${type})\` keyword is disallowed. ` + `(You specified \`(${type} ${original})\` and \`${original}\` evaluated into "${nameOrValue}".) ` + `This ensures we can statically analyze the template and determine which ${type}s are used. ` + `If the ${type} name is always the same, use a string literal instead, i.e. \`(${type} "${nameOrValue}")\`. ` + `Otherwise, import the ${type}s into JavaScript and pass them directly. ` + 'See https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#4-no-dynamic-resolution for details. ' + loc, typeof nameOrValue !== 'string');
4579
4581
  return nameOrValue;
4580
4582
  });
4581
4583
  });
@@ -5165,6 +5167,7 @@ class ActionModifierManager {
5165
5167
 
5166
5168
  ensureEventSetup(actionState) {
5167
5169
  let dispatcher = actionState.owner.lookup('event_dispatcher:main');
5170
+ assert('Expected dispatcher to be an EventDispatcher', dispatcher instanceof EventDispatcher);
5168
5171
  dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.setupHandlerForEmberEvent(actionState.eventName);
5169
5172
  }
5170
5173
 
@@ -5218,6 +5221,7 @@ class MountManager {
5218
5221
  // mount is a runtime helper, this shouldn't use dynamic layout
5219
5222
  // we should resolve the engine app template in the helper
5220
5223
  // it also should use the owner that looked up the mount helper.
5224
+ assert('Expected owner to be an EngineInstance', owner instanceof EngineInstance);
5221
5225
  let engine = owner.buildChildEngineInstance(name);
5222
5226
  engine.boot();
5223
5227
  let applicationFactory = engine.factoryFor(`controller:application`);
@@ -5430,28 +5434,17 @@ const mountHelper = internalHelper((args, owner) => {
5430
5434
  Note: Your content __will not render__ if there isn't an `{{outlet}}` for it.
5431
5435
 
5432
5436
  @method outlet
5433
- @param {String} [name]
5434
5437
  @for Ember.Templates.helpers
5435
5438
  @public
5436
5439
  */
5437
5440
 
5438
- const outletHelper = internalHelper((args, owner, scope) => {
5441
+ const outletHelper = internalHelper((_args, owner, scope) => {
5439
5442
  assert('Expected owner to be present, {{outlet}} requires an owner', owner);
5440
5443
  assert('Expected dynamic scope to be present. You may have attempted to use the {{outlet}} keyword dynamically. This keyword cannot be used dynamically.', scope);
5441
- let nameRef;
5442
-
5443
- if (args.positional.length === 0) {
5444
- nameRef = createPrimitiveRef('main');
5445
- } else {
5446
- let maybeNameRef = args.positional[0];
5447
- assert('Expected at least one positional arg', maybeNameRef);
5448
- nameRef = maybeNameRef;
5449
- }
5450
-
5451
5444
  let outletRef = createComputeRef(() => {
5452
5445
  let state = valueForRef(scope.get('outletState'));
5453
5446
  let outlets = state !== undefined ? state.outlets : undefined;
5454
- return outlets !== undefined ? outlets[valueForRef(nameRef)] : undefined;
5447
+ return outlets !== undefined ? outlets.main : undefined;
5455
5448
  });
5456
5449
  let lastState = null;
5457
5450
  let definition = null;
@@ -5541,9 +5534,9 @@ function instrumentationPayload$1(name) {
5541
5534
  };
5542
5535
  }
5543
5536
 
5544
- function componentFor(name, owner, options) {
5537
+ function componentFor(name, owner) {
5545
5538
  let fullName = `component:${name}`;
5546
- return owner.factoryFor(fullName, options) || null;
5539
+ return owner.factoryFor(fullName) || null;
5547
5540
  }
5548
5541
 
5549
5542
  function layoutFor(name, owner, options) {
@@ -5552,7 +5545,7 @@ function layoutFor(name, owner, options) {
5552
5545
  }
5553
5546
 
5554
5547
  function lookupComponentPair(owner, name, options) {
5555
- let component = componentFor(name, owner, options);
5548
+ let component = componentFor(name, owner);
5556
5549
 
5557
5550
  if (component !== null && component.class !== undefined) {
5558
5551
  let layout = getComponentTemplate(component.class);
@@ -1782,20 +1782,20 @@ function get(obj, keyName) {
1782
1782
  return isPath(keyName) ? _getPath(obj, keyName) : _getProp(obj, keyName);
1783
1783
  }
1784
1784
  function _getProp(obj, keyName) {
1785
- let type = typeof obj;
1786
- let isObject$$1 = type === 'object';
1787
- let isFunction = type === 'function';
1788
- let isObjectLike = isObject$$1 || isFunction;
1785
+ if (obj == null) {
1786
+ return;
1787
+ }
1788
+
1789
1789
  let value;
1790
1790
 
1791
- if (isObjectLike) {
1791
+ if (typeof obj === 'object' || typeof obj === 'function') {
1792
1792
  if (DEBUG) {
1793
1793
  value = getPossibleMandatoryProxyValue(obj, keyName);
1794
1794
  } else {
1795
1795
  value = obj[keyName];
1796
1796
  }
1797
1797
 
1798
- if (value === undefined && isObject$$1 && !(keyName in obj) && typeof obj.unknownProperty === 'function') {
1798
+ if (value === undefined && typeof obj === 'object' && !(keyName in obj) && typeof obj.unknownProperty === 'function') {
1799
1799
  value = obj.unknownProperty(keyName);
1800
1800
  }
1801
1801
 
@@ -1809,13 +1809,13 @@ function _getProp(obj, keyName) {
1809
1809
  }
1810
1810
  }
1811
1811
  } else {
1812
+ // SAFETY: It should be ok to access properties on any non-nullish value
1812
1813
  value = obj[keyName];
1813
1814
  }
1814
1815
 
1815
1816
  return value;
1816
1817
  }
1817
- function _getPath(root, path) {
1818
- let obj = root;
1818
+ function _getPath(obj, path) {
1819
1819
  let parts = typeof path === 'string' ? path.split('.') : path;
1820
1820
 
1821
1821
  for (let part of parts) {
@@ -1838,12 +1838,12 @@ _getProp({}, 'a');
1838
1838
  _getProp({}, 1);
1839
1839
 
1840
1840
  _getProp({
1841
- unkonwnProperty() {}
1841
+ unknownProperty() {}
1842
1842
 
1843
1843
  }, 'a');
1844
1844
 
1845
1845
  _getProp({
1846
- unkonwnProperty() {}
1846
+ unknownProperty() {}
1847
1847
 
1848
1848
  }, 1);
1849
1849
 
@@ -2201,13 +2201,7 @@ function isEmpty(obj) {
2201
2201
  if (typeof size === 'number') {
2202
2202
  return !size;
2203
2203
  }
2204
- }
2205
2204
 
2206
- if (typeof obj.length === 'number' && objectType !== 'function') {
2207
- return !obj.length;
2208
- }
2209
-
2210
- if (objectType === 'object') {
2211
2205
  let length = get(obj, 'length');
2212
2206
 
2213
2207
  if (typeof length === 'number') {
@@ -2215,6 +2209,10 @@ function isEmpty(obj) {
2215
2209
  }
2216
2210
  }
2217
2211
 
2212
+ if (typeof obj.length === 'number' && objectType !== 'function') {
2213
+ return !obj.length;
2214
+ }
2215
+
2218
2216
  return false;
2219
2217
  }
2220
2218
 
@@ -13,6 +13,7 @@ import { assert } from '@ember/debug';
13
13
  import { readOnly } from '@ember/object/computed';
14
14
  import Service from '@ember/service';
15
15
  import { consumeTag, tagFor } from '@glimmer/validator';
16
+ import EmberRouter from '../system/router';
16
17
  import { extractRouteArgs, resemblesURL, shallowEqual } from '../utils';
17
18
  const ROUTER = symbol('ROUTER');
18
19
 
@@ -133,6 +134,7 @@ class RouterService extends Service.extend(Evented) {
133
134
  let owner = getOwner(this);
134
135
  assert('RouterService is unexpectedly missing an owner', owner);
135
136
  router = owner.lookup('router:main');
137
+ assert('ROUTER SERVICE BUG: Expected router to be an instance of EmberRouter', router instanceof EmberRouter);
136
138
  return this[ROUTER] = router;
137
139
  }
138
140
 
@@ -6,6 +6,7 @@ import { symbol } from '@ember/-internals/utils';
6
6
  import { assert } from '@ember/debug';
7
7
  import { readOnly } from '@ember/object/computed';
8
8
  import Service from '@ember/service';
9
+ import EmberRouter from '../system/router';
9
10
  const ROUTER = symbol('ROUTER');
10
11
  /**
11
12
  The Routing service is used by LinkTo, and provides facilities for
@@ -29,6 +30,7 @@ export default class RoutingService extends Service {
29
30
  let owner = getOwner(this);
30
31
  assert('RoutingService is unexpectedly missing an owner', owner);
31
32
  router = owner.lookup('router:main');
33
+ assert('ROUTING SERVICE BUG: Expected router to be an instance of EmberRouter', router instanceof EmberRouter);
32
34
  router.setupRouter();
33
35
  return this[ROUTER] = router;
34
36
  }
@@ -1,5 +1,6 @@
1
1
  import { get } from '@ember/-internals/metal';
2
- import { info } from '@ember/debug';
2
+ import Controller from '@ember/controller';
3
+ import { assert, info } from '@ember/debug';
3
4
  import { DEBUG } from '@glimmer/env';
4
5
  /**
5
6
  @module ember
@@ -39,6 +40,7 @@ export default function generateController(owner, controllerName) {
39
40
  generateControllerFactory(owner, controllerName);
40
41
  let fullName = `controller:${controllerName}`;
41
42
  let instance = owner.lookup(fullName);
43
+ assert('Expected an instance of controller', instance instanceof Controller);
42
44
 
43
45
  if (DEBUG) {
44
46
  if (get(instance, 'namespace.LOG_ACTIVE_GENERATION')) {
@@ -9,27 +9,31 @@ var __decorate = this && this.__decorate || function (decorators, target, key, d
9
9
  import { privatize as P } from '@ember/-internals/container';
10
10
  import { addObserver, computed, defineProperty, descriptorForProperty, flushAsyncObservers, get, getProperties, isEmpty, set, setProperties } from '@ember/-internals/metal';
11
11
  import { getOwner } from '@ember/-internals/owner';
12
+ import { BucketCache } from '@ember/-internals/routing';
12
13
  import { A as emberA, ActionHandler, Evented, Object as EmberObject, typeOf } from '@ember/-internals/runtime';
13
14
  import { isProxy, lookupDescriptor, symbol } from '@ember/-internals/utils';
15
+ import Controller from '@ember/controller';
14
16
  import { assert, info, isTesting } from '@ember/debug';
17
+ import EngineInstance from '@ember/engine/instance';
15
18
  import { dependentKeyCompat } from '@ember/object/compat';
16
19
  import { once } from '@ember/runloop';
17
20
  import { DEBUG } from '@glimmer/env';
18
21
  import { PARAMS_SYMBOL, STATE_SYMBOL } from 'router_js';
19
22
  import { calculateCacheKey, deprecateTransitionMethods, normalizeControllerQueryParams, prefixRouteNameArg, stashParamNames } from '../utils';
20
23
  import generateController from './generate_controller';
24
+ import EmberRouter from './router';
21
25
  export const ROUTE_CONNECTIONS = new WeakMap();
22
26
  const RENDER = symbol('render');
23
27
 
24
28
  class Route extends EmberObject.extend(ActionHandler, Evented) {
25
29
  constructor(owner) {
26
- super(...arguments);
30
+ super(owner);
27
31
  this.context = {};
28
32
 
29
33
  if (owner) {
30
34
  let router = owner.lookup('router:main');
31
35
  let bucketCache = owner.lookup(P`-bucket-cache:main`);
32
- assert('ROUTER BUG: Expected route injections to be defined on the route. This is an internal bug, please open an issue on Github if you see this message!', router && bucketCache);
36
+ assert('ROUTER BUG: Expected route injections to be defined on the route. This is an internal bug, please open an issue on Github if you see this message!', router instanceof EmberRouter && bucketCache instanceof BucketCache);
33
37
  this._router = router;
34
38
  this._bucketCache = bucketCache;
35
39
  this._topLevelViewTemplate = owner.lookup('template:-outlet');
@@ -110,7 +114,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
110
114
  _setRouteName(name) {
111
115
  this.routeName = name;
112
116
  let owner = getOwner(this);
113
- assert('Route is unexpectedly missing an owner', owner);
117
+ assert('Expected route to have EngineInstance as owner', owner instanceof EngineInstance);
114
118
  this.fullRouteName = getEngineRouteName(owner, name);
115
119
  }
116
120
  /**
@@ -943,6 +947,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
943
947
  // passed a model to skip the assertion.
944
948
 
945
949
  assert(`The controller named '${name}' could not be found. Make sure that this route exists and has already been entered at least once. If you are accessing a controller not associated with a route, make sure the controller class is explicitly defined.`, controller !== undefined || _skipAssert === true);
950
+ assert(`Expected controller:${name} to be an instance of Controller`, controller === undefined || controller instanceof Controller);
946
951
  return controller;
947
952
  }
948
953
  /**
@@ -1007,7 +1012,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
1007
1012
  modelFor(_name) {
1008
1013
  let name;
1009
1014
  let owner = getOwner(this);
1010
- assert('Route is unexpectedly missing an owner', owner);
1015
+ assert('Expected router owner to be an EngineInstance', owner instanceof EngineInstance);
1011
1016
  let transition = this._router && this._router._routerMicrolib ? this._router._routerMicrolib.activeTransition : undefined; // Only change the route name when there is an active transition.
1012
1017
  // Otherwise, use the passed in route name.
1013
1018
 
@@ -1135,10 +1140,11 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
1135
1140
  let hasRouterDefinedQueryParams = Object.keys(queryParameterConfiguraton).length > 0;
1136
1141
 
1137
1142
  if (controller) {
1138
- // the developer has authored a controller class in their application for
1143
+ assert('Expected an instance of controller', controller instanceof Controller); // the developer has authored a controller class in their application for
1139
1144
  // this route find its query params and normalize their object shape them
1140
1145
  // merge in the query params for the route. As a mergedProperty,
1141
1146
  // Route#queryParams is always at least `{}`
1147
+
1142
1148
  let controllerDefinedQueryParameterConfiguration = get(controller, 'queryParams') || [];
1143
1149
  let normalizedControllerQueryParameterConfiguration = normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration);
1144
1150
  combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton);
@@ -1298,7 +1304,7 @@ function buildRenderOptions(route, nameOrOptions, options) {
1298
1304
  let owner = getOwner(route);
1299
1305
  assert('Route is unexpectedly missing an owner', owner);
1300
1306
  let name, templateName, into, outlet, model;
1301
- let controller = undefined;
1307
+ let controller;
1302
1308
 
1303
1309
  if (options) {
1304
1310
  into = options.into && options.into.replace(/\//g, '.');
@@ -1331,6 +1337,8 @@ function buildRenderOptions(route, nameOrOptions, options) {
1331
1337
  assert(`You passed \`controller: '${controllerName}'\` into the \`render\` method, but no such controller could be found.`, isDefaultRender || controller !== undefined);
1332
1338
  }
1333
1339
 
1340
+ assert('Expected an instance of controller', controller instanceof Controller);
1341
+
1334
1342
  if (model === undefined) {
1335
1343
  model = route.currentModel;
1336
1344
  } else {
@@ -1,6 +1,7 @@
1
1
  import { privatize as P } from '@ember/-internals/container';
2
2
  import { computed, get, set } from '@ember/-internals/metal';
3
3
  import { getOwner } from '@ember/-internals/owner';
4
+ import { BucketCache } from '@ember/-internals/routing';
4
5
  import { A as emberA, Evented, Object as EmberObject, typeOf } from '@ember/-internals/runtime';
5
6
  import { assert, deprecate, info } from '@ember/debug';
6
7
  import EmberError from '@ember/error';
@@ -16,6 +17,7 @@ import RouterState from './router_state';
16
17
  */
17
18
 
18
19
  import Router, { logAbort, STATE_SYMBOL } from 'router_js';
20
+ import EngineInstance from '@ember/engine/instance';
19
21
 
20
22
  function defaultDidTransition(infos) {
21
23
  updatePaths(this);
@@ -77,7 +79,7 @@ const {
77
79
 
78
80
  class EmberRouter extends EmberObject.extend(Evented) {
79
81
  constructor(owner) {
80
- super(...arguments);
82
+ super(owner);
81
83
  this._didSetupRouter = false;
82
84
  this._initialTransitionStarted = false;
83
85
  this.currentURL = null;
@@ -99,7 +101,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
99
101
 
100
102
  this.namespace = owner.lookup('application:main');
101
103
  let bucketCache = owner.lookup(P`-bucket-cache:main`);
102
- assert('BUG: BucketCache should always be present', bucketCache !== undefined);
104
+ assert('BUG: BucketCache should always be present', bucketCache instanceof BucketCache);
103
105
  this._bucketCache = bucketCache;
104
106
  let routerService = owner.lookup('service:router');
105
107
  assert('BUG: RouterService should always be present', routerService !== undefined);
@@ -1221,7 +1223,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
1221
1223
 
1222
1224
  if (!engineInstance) {
1223
1225
  let owner = getOwner(this);
1224
- assert('Router is unexpectedly missing an owner', owner);
1226
+ assert('Expected router to have EngineInstance as owner', owner instanceof EngineInstance);
1225
1227
  assert(`You attempted to mount the engine '${name}' in your router map, but the engine can not be found.`, owner.hasRegistration(`engine:${name}`));
1226
1228
  engineInstance = owner.buildChildEngineInstance(name, {
1227
1229
  routable: true,
@@ -1526,16 +1528,6 @@ function updatePaths(router) {
1526
1528
  set(router, 'currentPath', path);
1527
1529
  set(router, 'currentRouteName', currentRouteName);
1528
1530
  set(router, 'currentURL', currentURL);
1529
- let owner = getOwner(router);
1530
- assert('Router is unexpectedly missing an owner', owner);
1531
- let appController = owner.lookup('controller:application');
1532
-
1533
- if (!appController) {
1534
- // appController might not exist when top-level loading/error
1535
- // substates have been entered since ApplicationRoute hasn't
1536
- // actually been entered at that point.
1537
- return;
1538
- }
1539
1531
  }
1540
1532
 
1541
1533
  function didBeginTransition(transition, router) {
@@ -1,6 +1,7 @@
1
1
  import { get } from '@ember/-internals/metal';
2
2
  import { getOwner } from '@ember/-internals/owner';
3
3
  import { assert, deprecate } from '@ember/debug';
4
+ import EngineInstance from '@ember/engine/instance';
4
5
  import EmberError from '@ember/error';
5
6
  import { STATE_SYMBOL } from 'router_js';
6
7
  const ALL_PERIODS_REGEX = /\./g;
@@ -219,7 +220,7 @@ export function resemblesURL(str) {
219
220
  export function prefixRouteNameArg(route, args) {
220
221
  let routeName;
221
222
  let owner = getOwner(route);
222
- assert('Route is unexpectedly missing an owner', owner);
223
+ assert('Expected route to have EngineInstance as owner', owner instanceof EngineInstance);
223
224
  let prefix = owner.mountPoint; // only alter the routeName if it's actually referencing a route.
224
225
 
225
226
  if (owner.routable && typeof args[0] === 'string') {
@@ -15,7 +15,7 @@ import { Mixin } from '@ember/-internals/metal';
15
15
  let containerProxyMixin = {
16
16
  /**
17
17
  The container stores state.
18
- @private
18
+ @private
19
19
  @property {Ember.Container} __container__
20
20
  */
21
21
  __container__: null,
@@ -23,16 +23,16 @@ let containerProxyMixin = {
23
23
  /**
24
24
  Returns an object that can be used to provide an owner to a
25
25
  manually created instance.
26
- Example:
27
- ```
26
+ Example:
27
+ ```
28
28
  import { getOwner } from '@ember/application';
29
- let owner = getOwner(this);
30
- User.create(
29
+ let owner = getOwner(this);
30
+ User.create(
31
31
  owner.ownerInjection(),
32
32
  { username: 'rwjblue' }
33
33
  )
34
34
  ```
35
- @public
35
+ @public
36
36
  @method ownerInjection
37
37
  @since 2.3.0
38
38
  @return {Object}
@@ -43,30 +43,30 @@ let containerProxyMixin = {
43
43
 
44
44
  /**
45
45
  Given a fullName return a corresponding instance.
46
- The default behavior is for lookup to return a singleton instance.
46
+ The default behavior is for lookup to return a singleton instance.
47
47
  The singleton is scoped to the container, allowing multiple containers
48
48
  to all have their own locally scoped singletons.
49
- ```javascript
49
+ ```javascript
50
50
  let registry = new Registry();
51
51
  let container = registry.container();
52
- registry.register('api:twitter', Twitter);
53
- let twitter = container.lookup('api:twitter');
54
- twitter instanceof Twitter; // => true
55
- // by default the container will return singletons
52
+ registry.register('api:twitter', Twitter);
53
+ let twitter = container.lookup('api:twitter');
54
+ twitter instanceof Twitter; // => true
55
+ // by default the container will return singletons
56
56
  let twitter2 = container.lookup('api:twitter');
57
57
  twitter2 instanceof Twitter; // => true
58
- twitter === twitter2; //=> true
58
+ twitter === twitter2; //=> true
59
59
  ```
60
- If singletons are not wanted an optional flag can be provided at lookup.
61
- ```javascript
60
+ If singletons are not wanted an optional flag can be provided at lookup.
61
+ ```javascript
62
62
  let registry = new Registry();
63
63
  let container = registry.container();
64
- registry.register('api:twitter', Twitter);
65
- let twitter = container.lookup('api:twitter', { singleton: false });
64
+ registry.register('api:twitter', Twitter);
65
+ let twitter = container.lookup('api:twitter', { singleton: false });
66
66
  let twitter2 = container.lookup('api:twitter', { singleton: false });
67
- twitter === twitter2; //=> false
67
+ twitter === twitter2; //=> false
68
68
  ```
69
- @public
69
+ @public
70
70
  @method lookup
71
71
  @param {String} fullName
72
72
  @param {Object} options
@@ -91,32 +91,32 @@ let containerProxyMixin = {
91
91
 
92
92
  /**
93
93
  Given a fullName return a factory manager.
94
- This method returns a manager which can be used for introspection of the
94
+ This method returns a manager which can be used for introspection of the
95
95
  factory's class or for the creation of factory instances with initial
96
96
  properties. The manager is an object with the following properties:
97
- * `class` - The registered or resolved class.
97
+ * `class` - The registered or resolved class.
98
98
  * `create` - A function that will create an instance of the class with
99
99
  any dependencies injected.
100
- For example:
101
- ```javascript
100
+ For example:
101
+ ```javascript
102
102
  import { getOwner } from '@ember/application';
103
- let owner = getOwner(otherInstance);
103
+ let owner = getOwner(otherInstance);
104
104
  // the owner is commonly the `applicationInstance`, and can be accessed via
105
105
  // an instance initializer.
106
- let factory = owner.factoryFor('service:bespoke');
107
- factory.class;
106
+ let factory = owner.factoryFor('service:bespoke');
107
+ factory.class;
108
108
  // The registered or resolved class. For example when used with an Ember-CLI
109
109
  // app, this would be the default export from `app/services/bespoke.js`.
110
- let instance = factory.create({
110
+ let instance = factory.create({
111
111
  someProperty: 'an initial property value'
112
112
  });
113
113
  // Create an instance with any injections and the passed options as
114
114
  // initial properties.
115
115
  ```
116
- Any instances created via the factory's `.create()` method *must* be destroyed
116
+ Any instances created via the factory's `.create()` method *must* be destroyed
117
117
  manually by the caller of `.create()`. Typically, this is done during the creating
118
118
  objects own `destroy` or `willDestroy` methods.
119
- @public
119
+ @public
120
120
  @method factoryFor
121
121
  @param {String} fullName
122
122
  @param {Object} options