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

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 (44) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/build-metadata.json +3 -3
  3. package/dist/dependencies/router_js.js +66 -31
  4. package/dist/ember-template-compiler.js +1169 -779
  5. package/dist/ember-template-compiler.map +1 -1
  6. package/dist/ember-testing.js +74 -43
  7. package/dist/ember-testing.map +1 -1
  8. package/dist/ember.debug.js +3290 -2760
  9. package/dist/ember.debug.map +1 -1
  10. package/dist/header/license.js +1 -1
  11. package/dist/packages/@ember/-internals/container/index.js +15 -11
  12. package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +3 -3
  13. package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +52 -52
  14. package/dist/packages/@ember/-internals/glimmer/index.js +139 -103
  15. package/dist/packages/@ember/-internals/meta/lib/meta.js +8 -9
  16. package/dist/packages/@ember/-internals/metal/index.js +44 -45
  17. package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +10 -8
  18. package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +3 -1
  19. package/dist/packages/@ember/-internals/routing/lib/services/router.js +155 -190
  20. package/dist/packages/@ember/-internals/routing/lib/services/routing.js +3 -1
  21. package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +2 -2
  22. package/dist/packages/@ember/-internals/routing/lib/system/route.js +110 -378
  23. package/dist/packages/@ember/-internals/routing/lib/system/router.js +74 -36
  24. package/dist/packages/@ember/-internals/routing/lib/utils.js +33 -21
  25. package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
  26. package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -0
  27. package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +4 -4
  28. package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +29 -29
  29. package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +16 -16
  30. package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +48 -48
  31. package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +8 -8
  32. package/dist/packages/@ember/-internals/runtime/lib/system/namespace.js +1 -2
  33. package/dist/packages/@ember/-internals/runtime/lib/type-of.js +1 -1
  34. package/dist/packages/@ember/-internals/utils/index.js +10 -8
  35. package/dist/packages/@ember/-internals/views/lib/system/utils.js +2 -0
  36. package/dist/packages/@ember/array/index.js +1 -1
  37. package/dist/packages/@ember/controller/index.js +3 -54
  38. package/dist/packages/@ember/instrumentation/index.js +9 -13
  39. package/dist/packages/@ember/object/compat.js +16 -7
  40. package/dist/packages/@ember/routing/router-service.js +1 -0
  41. package/dist/packages/@ember/service/index.js +6 -73
  42. package/dist/packages/ember/version.js +1 -1
  43. package/docs/data.json +571 -521
  44. package/package.json +13 -13
@@ -11,6 +11,10 @@ import { calculateCacheKey, extractRouteArgs, getActiveTargetName, resemblesURL
11
11
  import DSL from './dsl';
12
12
  import { defaultSerialize, getFullQueryParams, hasDefaultSerialize, ROUTE_CONNECTIONS } from './route';
13
13
  import RouterState from './router_state';
14
+ /**
15
+ @module @ember/routing
16
+ */
17
+
14
18
  import Router, { logAbort, STATE_SYMBOL } from 'router_js';
15
19
 
16
20
  function defaultDidTransition(infos) {
@@ -166,7 +170,9 @@ class EmberRouter extends EmberObject.extend(Evented) {
166
170
  let name, nameParts, oldNameParts;
167
171
 
168
172
  for (let i = 1; i < routeInfos.length; i++) {
169
- name = routeInfos[i].name;
173
+ let routeInfo = routeInfos[i];
174
+ assert('has routeInfo', routeInfo);
175
+ name = routeInfo.name;
170
176
  nameParts = name.split('.');
171
177
  oldNameParts = slice.call(path);
172
178
 
@@ -187,7 +193,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
187
193
  _initRouterJs() {
188
194
  let location = get(this, 'location');
189
195
  let router = this;
190
- let owner = getOwner(this);
196
+ const owner = getOwner(this);
197
+ assert('Router is unexpectedly missing an owner', owner);
191
198
  let seen = Object.create(null);
192
199
 
193
200
  class PrivateRouter extends Router {
@@ -204,6 +211,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
204
211
  }
205
212
 
206
213
  let fullRouteName = `route:${routeName}`;
214
+ assert('Route is unexpectedly missing an owner', routeOwner);
207
215
  let route = routeOwner.lookup(fullRouteName);
208
216
 
209
217
  if (seen[name]) {
@@ -368,7 +376,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
368
376
  let enableLoadingSubstates = this._hasModuleBasedResolver();
369
377
 
370
378
  let router = this;
371
- let owner = getOwner(this);
379
+ const owner = getOwner(this);
380
+ assert('Router is unexpectedly missing an owner', owner);
372
381
  let options = {
373
382
  enableLoadingSubstates,
374
383
 
@@ -398,6 +407,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
398
407
 
399
408
  _hasModuleBasedResolver() {
400
409
  let owner = getOwner(this);
410
+ assert('Router is unexpectedly missing an owner', owner);
401
411
  let resolver = get(owner, 'application.__registry__.resolver.moduleBasedResolver');
402
412
  return Boolean(resolver);
403
413
  }
@@ -468,8 +478,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
468
478
  let defaultParentState;
469
479
  let liveRoutes = null;
470
480
 
471
- for (let i = 0; i < routeInfos.length; i++) {
472
- let route = routeInfos[i].route;
481
+ for (let routeInfo of routeInfos) {
482
+ let route = routeInfo.route;
473
483
  let connections = ROUTE_CONNECTIONS.get(route);
474
484
  let ownState;
475
485
 
@@ -504,6 +514,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
504
514
 
505
515
  if (!this._toplevelView) {
506
516
  let owner = getOwner(this);
517
+ assert('Router is unexpectedly missing an owner', owner);
507
518
  let OutletView = owner.factoryFor('view:-outlet');
508
519
  let application = owner.lookup('application:main');
509
520
  let environment = owner.lookup('-environment:main');
@@ -544,9 +555,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
544
555
  /**
545
556
  Transition the application into another route. The route may
546
557
  be either a single route or route path:
547
- See [transitionTo](/ember/release/classes/Route/methods/transitionTo?anchor=transitionTo) for more info.
548
558
  @method transitionTo
549
- @param {String} name the name of the route or a URL
559
+ @param {String} [name] the name of the route or a URL
550
560
  @param {...Object} models the model(s) or identifier(s) to be used while
551
561
  transitioning to the route.
552
562
  @param {Object} [options] optional hash with a queryParams property
@@ -587,6 +597,23 @@ class EmberRouter extends EmberObject.extend(Evented) {
587
597
  }
588
598
  }
589
599
  }
600
+ /**
601
+ Similar to `transitionTo`, but instead of adding the destination to the browser's URL history,
602
+ it replaces the entry for the current route.
603
+ When the user clicks the "back" button in the browser, there will be fewer steps.
604
+ This is most commonly used to manage redirects in a way that does not cause confusing additions
605
+ to the user's browsing history.
606
+ @method replaceWith
607
+ @param {String} [name] the name of the route or a URL
608
+ @param {...Object} models the model(s) or identifier(s) to be used while
609
+ transitioning to the route.
610
+ @param {Object} [options] optional hash with a queryParams property
611
+ containing a mapping of query parameters
612
+ @return {Transition} the transition object associated with this
613
+ attempted transition
614
+ @public
615
+ */
616
+
590
617
 
591
618
  replaceWith(...args) {
592
619
  return this.transitionTo(...args).method('replace');
@@ -672,8 +699,11 @@ class EmberRouter extends EmberObject.extend(Evented) {
672
699
  let instances = this._engineInstances;
673
700
 
674
701
  for (let name in instances) {
675
- for (let id in instances[name]) {
676
- run(instances[name][id], 'destroy');
702
+ let instance = instances[name];
703
+ assert('has instance', instance);
704
+
705
+ for (let id in instance) {
706
+ run(instance[id], 'destroy');
677
707
  }
678
708
  }
679
709
  }
@@ -720,6 +750,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
720
750
  let location = this.location;
721
751
  let rootURL = this.rootURL;
722
752
  let owner = getOwner(this);
753
+ assert('Router is unexpectedly missing an owner', owner);
723
754
 
724
755
  if ('string' === typeof location) {
725
756
  let resolvedLocation = owner.lookup(`location:${location}`);
@@ -994,12 +1025,11 @@ class EmberRouter extends EmberObject.extend(Evented) {
994
1025
  let qps = [];
995
1026
  let qpsByUrlKey = DEBUG ? {} : null;
996
1027
  let qpMeta;
997
- let qp;
998
1028
  let urlKey;
999
1029
  let qpOther;
1000
1030
 
1001
- for (let i = 0; i < routeInfoLength; ++i) {
1002
- qpMeta = this._getQPMeta(routeInfos[i]);
1031
+ for (let routeInfo of routeInfos) {
1032
+ qpMeta = this._getQPMeta(routeInfo);
1003
1033
 
1004
1034
  if (!qpMeta) {
1005
1035
  shouldCache = false;
@@ -1007,9 +1037,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
1007
1037
  } // Loop over each QP to make sure we don't have any collisions by urlKey
1008
1038
 
1009
1039
 
1010
- for (let i = 0; i < qpMeta.qps.length; i++) {
1011
- qp = qpMeta.qps[i];
1012
-
1040
+ for (let qp of qpMeta.qps) {
1013
1041
  if (DEBUG) {
1014
1042
  urlKey = qp.urlKey;
1015
1043
  qpOther = qpsByUrlKey[urlKey];
@@ -1055,19 +1083,15 @@ class EmberRouter extends EmberObject.extend(Evented) {
1055
1083
  let routeInfos = state.routeInfos;
1056
1084
  let qpMeta;
1057
1085
 
1058
- for (let i = 0, len = routeInfos.length; i < len; ++i) {
1059
- qpMeta = this._getQPMeta(routeInfos[i]);
1086
+ for (let routeInfo of routeInfos) {
1087
+ qpMeta = this._getQPMeta(routeInfo);
1060
1088
 
1061
1089
  if (!qpMeta) {
1062
1090
  continue;
1063
1091
  }
1064
1092
 
1065
- let qp;
1066
- let presentProp;
1067
-
1068
- for (let j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) {
1069
- qp = qpMeta.qps[j];
1070
- presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey;
1093
+ for (let qp of qpMeta.qps) {
1094
+ let presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey;
1071
1095
 
1072
1096
  if (presentProp) {
1073
1097
  if (presentProp !== qp.scopedPropertyName) {
@@ -1097,15 +1121,17 @@ class EmberRouter extends EmberObject.extend(Evented) {
1097
1121
  let qp;
1098
1122
  let presentProp;
1099
1123
 
1100
- for (let i = 0; i < routeInfos.length; ++i) {
1101
- qpMeta = this._getQPMeta(routeInfos[i]);
1124
+ for (let routeInfo of routeInfos) {
1125
+ qpMeta = this._getQPMeta(routeInfo);
1102
1126
 
1103
1127
  if (!qpMeta) {
1104
1128
  continue;
1105
- }
1129
+ } // Needs to stay for index loop to avoid throwIfClosureRequired
1130
+
1106
1131
 
1107
1132
  for (let j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) {
1108
1133
  qp = qpMeta.qps[j];
1134
+ assert('expected qp', qp);
1109
1135
  presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey;
1110
1136
  assert(`You passed the \`${presentProp}\` query parameter during a transition into ${qp.route.routeName}, please update to ${qp.urlKey}`, function () {
1111
1137
  if (qp.urlKey === presentProp || qp.scopedPropertyName === presentProp) {
@@ -1182,22 +1208,27 @@ class EmberRouter extends EmberObject.extend(Evented) {
1182
1208
  mountPoint
1183
1209
  }) {
1184
1210
  let engineInstances = this._engineInstances;
1211
+ let namedInstances = engineInstances[name];
1212
+
1213
+ if (!namedInstances) {
1214
+ namedInstances = Object.create(null);
1215
+ engineInstances[name] = namedInstances;
1216
+ } // We just set these!
1185
1217
 
1186
- if (!engineInstances[name]) {
1187
- engineInstances[name] = Object.create(null);
1188
- }
1189
1218
 
1190
- let engineInstance = engineInstances[name][instanceId];
1219
+ assert('has namedInstances', namedInstances);
1220
+ let engineInstance = namedInstances[instanceId];
1191
1221
 
1192
1222
  if (!engineInstance) {
1193
1223
  let owner = getOwner(this);
1224
+ assert('Router is unexpectedly missing an owner', owner);
1194
1225
  assert(`You attempted to mount the engine '${name}' in your router map, but the engine can not be found.`, owner.hasRegistration(`engine:${name}`));
1195
1226
  engineInstance = owner.buildChildEngineInstance(name, {
1196
1227
  routable: true,
1197
1228
  mountPoint
1198
1229
  });
1199
1230
  engineInstance.boot();
1200
- engineInstances[name][instanceId] = engineInstance;
1231
+ namedInstances[instanceId] = engineInstance;
1201
1232
  }
1202
1233
 
1203
1234
  return engineInstance;
@@ -1224,6 +1255,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
1224
1255
  function forEachRouteAbove(routeInfos, callback) {
1225
1256
  for (let i = routeInfos.length - 1; i >= 0; --i) {
1226
1257
  let routeInfo = routeInfos[i];
1258
+ assert('has routeInfo', routeInfo);
1227
1259
  let route = routeInfo.route; // routeInfo.handler being `undefined` generally means either:
1228
1260
  //
1229
1261
  // 1. an error occurred during creation of the route in question
@@ -1358,6 +1390,7 @@ function logError(_error, initialMessage) {
1358
1390
 
1359
1391
  function findRouteSubstateName(route, state) {
1360
1392
  let owner = getOwner(route);
1393
+ assert('Route is unexpectedly missing an owner', owner);
1361
1394
  let {
1362
1395
  routeName,
1363
1396
  fullRouteName,
@@ -1381,6 +1414,7 @@ function findRouteSubstateName(route, state) {
1381
1414
 
1382
1415
  function findRouteStateName(route, state) {
1383
1416
  let owner = getOwner(route);
1417
+ assert('Route is unexpectedly missing an owner', owner);
1384
1418
  let {
1385
1419
  routeName,
1386
1420
  fullRouteName,
@@ -1424,6 +1458,7 @@ export function triggerEvent(routeInfos, ignoreFailure, name, args) {
1424
1458
 
1425
1459
  for (let i = routeInfos.length - 1; i >= 0; i--) {
1426
1460
  routeInfo = routeInfos[i];
1461
+ assert('has routeInfo', routeInfo);
1427
1462
  handler = routeInfo.route;
1428
1463
  actionHandler = handler && handler.actions && handler.actions[name];
1429
1464
 
@@ -1461,9 +1496,8 @@ function calculatePostTransitionState(emberRouter, leafRouteName, contexts) {
1461
1496
  params
1462
1497
  } = state;
1463
1498
 
1464
- for (let i = 0; i < routeInfos.length; ++i) {
1465
- let routeInfo = routeInfos[i]; // If the routeInfo is not resolved, we serialize the context into params
1466
-
1499
+ for (let routeInfo of routeInfos) {
1500
+ // If the routeInfo is not resolved, we serialize the context into params
1467
1501
  if (!routeInfo.isResolved) {
1468
1502
  params[routeInfo.name] = routeInfo.serialize(routeInfo.context);
1469
1503
  } else {
@@ -1483,14 +1517,18 @@ function updatePaths(router) {
1483
1517
 
1484
1518
  let path = EmberRouter._routePath(infos);
1485
1519
 
1486
- let currentRouteName = infos[infos.length - 1].name;
1520
+ let info = infos[infos.length - 1];
1521
+ assert('expected info', info);
1522
+ let currentRouteName = info.name;
1487
1523
  let location = router.location;
1488
1524
  assert('expected location to not be a string', typeof location !== 'string');
1489
1525
  let currentURL = location.getURL();
1490
1526
  set(router, 'currentPath', path);
1491
1527
  set(router, 'currentRouteName', currentRouteName);
1492
1528
  set(router, 'currentURL', currentURL);
1493
- let appController = getOwner(router).lookup('controller:application');
1529
+ let owner = getOwner(router);
1530
+ assert('Router is unexpectedly missing an owner', owner);
1531
+ let appController = owner.lookup('controller:application');
1494
1532
 
1495
1533
  if (!appController) {
1496
1534
  // appController might not exist when top-level loading/error
@@ -1,26 +1,32 @@
1
1
  import { get } from '@ember/-internals/metal';
2
2
  import { getOwner } from '@ember/-internals/owner';
3
- import { deprecate } from '@ember/debug';
3
+ import { assert, deprecate } from '@ember/debug';
4
4
  import EmberError from '@ember/error';
5
5
  import { STATE_SYMBOL } from 'router_js';
6
6
  const ALL_PERIODS_REGEX = /\./g;
7
7
  export function extractRouteArgs(args) {
8
+ // SAFETY: This should just be the same thing
8
9
  args = args.slice();
9
- let possibleQueryParams = args.pop();
10
+ let possibleOptions = args[args.length - 1];
10
11
  let queryParams;
11
12
 
12
- if (hasQueryParams(possibleQueryParams)) {
13
- queryParams = possibleQueryParams.queryParams;
13
+ if (isRouteOptions(possibleOptions)) {
14
+ args.pop(); // Remove options
15
+
16
+ queryParams = possibleOptions.queryParams;
14
17
  } else {
15
- // Not query params so return to the array
16
- args.push(possibleQueryParams);
17
18
  queryParams = {};
18
- } // UNSAFE: these are simply assumed as the existing behavior of the system.
19
- // However, this could break if upstream refactors change it, and the types
20
- // here would not be able to tell us; we would lie to everything downstream.
19
+ }
20
+
21
+ let routeName;
22
+
23
+ if (typeof args[0] === 'string') {
24
+ routeName = args.shift(); // We just checked this!
25
+
26
+ assert('routeName is a string', typeof routeName === 'string');
27
+ } // SAFTEY: We removed the name and options if they existed, only models left.
21
28
 
22
29
 
23
- let routeName = args.shift();
24
30
  let models = args;
25
31
  return {
26
32
  routeName,
@@ -30,7 +36,9 @@ export function extractRouteArgs(args) {
30
36
  }
31
37
  export function getActiveTargetName(router) {
32
38
  let routeInfos = router.activeTransition ? router.activeTransition[STATE_SYMBOL].routeInfos : router.state.routeInfos;
33
- return routeInfos[routeInfos.length - 1].name;
39
+ let lastRouteInfo = routeInfos[routeInfos.length - 1];
40
+ assert('has last route info', lastRouteInfo);
41
+ return lastRouteInfo.name;
34
42
  }
35
43
  export function stashParamNames(router, routeInfos) {
36
44
  if (routeInfos['_namesStashed']) {
@@ -41,7 +49,9 @@ export function stashParamNames(router, routeInfos) {
41
49
  // Hopefully we can remove this in the future.
42
50
 
43
51
 
44
- let targetRouteName = routeInfos[routeInfos.length - 1].name;
52
+ let routeInfo = routeInfos[routeInfos.length - 1];
53
+ assert('has route info', routeInfo);
54
+ let targetRouteName = routeInfo.name;
45
55
 
46
56
  let recogHandlers = router._routerMicrolib.recognizer.handlersFor(targetRouteName);
47
57
 
@@ -49,6 +59,7 @@ export function stashParamNames(router, routeInfos) {
49
59
 
50
60
  for (let i = 0; i < routeInfos.length; ++i) {
51
61
  let routeInfo = routeInfos[i];
62
+ assert('has route info', routeInfo);
52
63
  let names = recogHandlers[i].names;
53
64
 
54
65
  if (names.length) {
@@ -56,7 +67,7 @@ export function stashParamNames(router, routeInfos) {
56
67
  }
57
68
 
58
69
  routeInfo['_names'] = names;
59
- let route = routeInfo.route;
70
+ let route = routeInfo.route; // SAFETY: This cast should be idential. I don't understand why it is needed.
60
71
 
61
72
  route._stashNames(routeInfo, dynamicParent);
62
73
  }
@@ -94,9 +105,7 @@ function _calculateCacheValuePrefix(prefix, part) {
94
105
  export function calculateCacheKey(prefix, parts = [], values) {
95
106
  let suffixes = '';
96
107
 
97
- for (let i = 0; i < parts.length; ++i) {
98
- let part = parts[i];
99
-
108
+ for (let part of parts) {
100
109
  let cacheValuePrefix = _calculateCacheValuePrefix(prefix, part);
101
110
 
102
111
  let value;
@@ -151,8 +160,8 @@ export function calculateCacheKey(prefix, parts = [], values) {
151
160
  export function normalizeControllerQueryParams(queryParams) {
152
161
  let qpMap = {};
153
162
 
154
- for (let i = 0; i < queryParams.length; ++i) {
155
- accumulateQueryParamDescriptors(queryParams[i], qpMap);
163
+ for (let queryParam of queryParams) {
164
+ accumulateQueryParamDescriptors(queryParam, qpMap);
156
165
  }
157
166
 
158
167
  return qpMap;
@@ -208,11 +217,14 @@ export function resemblesURL(str) {
208
217
  */
209
218
 
210
219
  export function prefixRouteNameArg(route, args) {
211
- let routeName = args[0];
220
+ let routeName;
212
221
  let owner = getOwner(route);
222
+ assert('Route is unexpectedly missing an owner', owner);
213
223
  let prefix = owner.mountPoint; // only alter the routeName if it's actually referencing a route.
214
224
 
215
- if (owner.routable && typeof routeName === 'string') {
225
+ if (owner.routable && typeof args[0] === 'string') {
226
+ routeName = args[0];
227
+
216
228
  if (resemblesURL(routeName)) {
217
229
  throw new EmberError('Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.');
218
230
  } else {
@@ -259,7 +271,7 @@ export function deprecateTransitionMethods(frameworkClass, methodName) {
259
271
  });
260
272
  }
261
273
 
262
- function hasQueryParams(value) {
274
+ function isRouteOptions(value) {
263
275
  if (value && typeof value === 'object') {
264
276
  let qps = value.queryParams;
265
277
 
@@ -53,7 +53,7 @@ function customTagForProxy(proxy, key, addMandatorySetter) {
53
53
  export default Mixin.create({
54
54
  /**
55
55
  The object whose properties will be forwarded.
56
- @property content
56
+ @property content
57
57
  @type {unknown}
58
58
  @default null
59
59
  @public
@@ -952,6 +952,7 @@ const ArrayMixin = Mixin.create(Enumerable, {
952
952
  @return {Object} The reduced value.
953
953
  @public
954
954
  */
955
+ // FIXME: When called without initialValue, behavior does not match native behavior
955
956
  reduce(callback, initialValue) {
956
957
  assert('`reduce` expects a function as first argument.', typeof callback === 'function');
957
958
  let ret = initialValue;
@@ -18,13 +18,13 @@ import { Mixin } from '@ember/-internals/metal';
18
18
  export default Mixin.create({
19
19
  /**
20
20
  __Required.__ You must implement this method to apply this mixin.
21
- Override to return the result of the comparison of the two parameters. The
21
+ Override to return the result of the comparison of the two parameters. The
22
22
  compare method should return:
23
- - `-1` if `a < b`
23
+ - `-1` if `a < b`
24
24
  - `0` if `a == b`
25
25
  - `1` if `a > b`
26
- Default implementation raises an exception.
27
- @method compare
26
+ Default implementation raises an exception.
27
+ @method compare
28
28
  @param a {Object} the first object to compare
29
29
  @param b {Object} the second object to compare
30
30
  @return {Number} the result of the comparison
@@ -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
@@ -98,7 +98,7 @@ export default Mixin.create({
98
98
  /**
99
99
  If the proxied promise is rejected this will contain the reason
100
100
  provided.
101
- @property reason
101
+ @property reason
102
102
  @default null
103
103
  @public
104
104
  */
@@ -106,7 +106,7 @@ export default Mixin.create({
106
106
 
107
107
  /**
108
108
  Once the proxied promise has settled this will become `false`.
109
- @property isPending
109
+ @property isPending
110
110
  @default true
111
111
  @public
112
112
  */
@@ -116,7 +116,7 @@ export default Mixin.create({
116
116
 
117
117
  /**
118
118
  Once the proxied promise has settled this will become `true`.
119
- @property isSettled
119
+ @property isSettled
120
120
  @default false
121
121
  @public
122
122
  */
@@ -126,7 +126,7 @@ export default Mixin.create({
126
126
 
127
127
  /**
128
128
  Will become `true` if the proxied promise is rejected.
129
- @property isRejected
129
+ @property isRejected
130
130
  @default false
131
131
  @public
132
132
  */
@@ -134,7 +134,7 @@ export default Mixin.create({
134
134
 
135
135
  /**
136
136
  Will become `true` if the proxied promise is fulfilled.
137
- @property isFulfilled
137
+ @property isFulfilled
138
138
  @default false
139
139
  @public
140
140
  */
@@ -142,17 +142,17 @@ export default Mixin.create({
142
142
 
143
143
  /**
144
144
  The promise whose fulfillment value is being proxied by this object.
145
- This property must be specified upon creation, and should not be
145
+ This property must be specified upon creation, and should not be
146
146
  changed once created.
147
- Example:
148
- ```javascript
147
+ Example:
148
+ ```javascript
149
149
  import ObjectProxy from '@ember/object/proxy';
150
150
  import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
151
- ObjectProxy.extend(PromiseProxyMixin).create({
151
+ ObjectProxy.extend(PromiseProxyMixin).create({
152
152
  promise: <thenable>
153
153
  });
154
154
  ```
155
- @property promise
155
+ @property promise
156
156
  @public
157
157
  */
158
158
  promise: computed({
@@ -168,8 +168,8 @@ export default Mixin.create({
168
168
 
169
169
  /**
170
170
  An alias to the proxied promise's `then`.
171
- See RSVP.Promise.then.
172
- @method then
171
+ See RSVP.Promise.then.
172
+ @method then
173
173
  @param {Function} callback
174
174
  @return {RSVP.Promise}
175
175
  @public
@@ -178,8 +178,8 @@ export default Mixin.create({
178
178
 
179
179
  /**
180
180
  An alias to the proxied promise's `catch`.
181
- See RSVP.Promise.catch.
182
- @method catch
181
+ See RSVP.Promise.catch.
182
+ @method catch
183
183
  @param {Function} callback
184
184
  @return {RSVP.Promise}
185
185
  @since 1.3.0
@@ -189,8 +189,8 @@ export default Mixin.create({
189
189
 
190
190
  /**
191
191
  An alias to the proxied promise's `finally`.
192
- See RSVP.Promise.finally.
193
- @method finally
192
+ See RSVP.Promise.finally.
193
+ @method finally
194
194
  @param {Function} callback
195
195
  @return {RSVP.Promise}
196
196
  @since 1.3.0