ember-source 4.1.0-alpha.7 → 4.2.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.
@@ -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.1.0-alpha.7
8
+ * @version 4.2.0-alpha.2
9
9
  */
@@ -4483,6 +4483,11 @@ setGlobalContext({
4483
4483
  let {
4484
4484
  id
4485
4485
  } = options;
4486
+
4487
+ if (id === 'argument-less-helper-paren-less-invocation') {
4488
+ throw new Error(`A resolved helper cannot be passed as a named argument as the syntax is ` + `ambiguously a pass-by-reference or invocation. Use the ` + `\`{{helper 'foo-helper}}\` helper to pass by reference or explicitly ` + `invoke the helper with parens: \`{{(fooHelper)}}\`.`);
4489
+ }
4490
+
4486
4491
  let override = VM_DEPRECATION_OVERRIDES.filter(o => o.id === id)[0];
4487
4492
  if (!override) throw new Error(`deprecation override for ${id} not found`); // allow deprecations to be disabled in the VM_DEPRECATION_OVERRIDES array below
4488
4493
 
@@ -4507,14 +4512,6 @@ if (DEBUG) {
4507
4512
 
4508
4513
 
4509
4514
  const VM_DEPRECATION_OVERRIDES = [{
4510
- id: 'argument-less-helper-paren-less-invocation',
4511
- url: 'https://deprecations.emberjs.com/v3.x#toc_argument-less-helper-paren-less-invocation',
4512
- until: '4.0.0',
4513
- for: 'ember-source',
4514
- since: {
4515
- enabled: '3.27.0'
4516
- }
4517
- }, {
4518
4515
  id: 'setting-on-hash',
4519
4516
  until: '4.4.0',
4520
4517
  for: 'ember-source',
@@ -1,5 +1,5 @@
1
1
  import { meta, peekMeta } from '@ember/-internals/meta';
2
- import { setListeners, isObject, setupMandatorySetter, symbol, toString, enumerableSymbol, getDebugName, inspect, setWithMandatorySetter, Cache, isEmberArray, setProxy, lookupDescriptor, getName, setName, guidFor, makeArray, observerListenerMetaFor, ROOT, setObservers, wrap } from '@ember/-internals/utils';
2
+ import { setListeners, isObject, setupMandatorySetter, symbol, toString, enumerableSymbol, inspect, setWithMandatorySetter, Cache, isEmberArray, setProxy, lookupDescriptor, getName, setName, guidFor, makeArray, observerListenerMetaFor, ROOT, setObservers, wrap } from '@ember/-internals/utils';
3
3
  import { assert, deprecate, debug, warn } from '@ember/debug';
4
4
  import { ENV, context } from '@ember/-internals/environment';
5
5
  import { schedule } from '@ember/runloop';
@@ -651,43 +651,29 @@ function replaceInNativeArray(array, start, deleteCount, items) {
651
651
  arrayContentDidChange(array, start, deleteCount, items.length);
652
652
  }
653
653
 
654
- function arrayObserversHelper(obj, target, opts, operation, notify) {
655
- let willChange = opts && opts.willChange || 'arrayWillChange';
656
- let didChange = opts && opts.didChange || 'arrayDidChange';
657
- let hasObservers = obj.hasArrayObservers;
654
+ function arrayObserversHelper(obj, target, opts, operation) {
655
+ var _a;
656
+
657
+ let {
658
+ willChange,
659
+ didChange
660
+ } = opts;
658
661
  operation(obj, '@array:before', target, willChange);
659
662
  operation(obj, '@array:change', target, didChange);
663
+ /*
664
+ * Array proxies have a `_revalidate` method which must be called to set
665
+ * up their internal array observation systems.
666
+ */
660
667
 
661
- if (hasObservers === notify) {
662
- notifyPropertyChange(obj, 'hasArrayObservers');
663
- }
664
-
668
+ (_a = obj._revalidate) === null || _a === void 0 ? void 0 : _a.call(obj);
665
669
  return obj;
666
670
  }
667
671
 
668
- function addArrayObserver(array, target, opts, suppress = false) {
669
- deprecate(`Array observers have been deprecated. Added an array observer to ${getDebugName === null || getDebugName === void 0 ? void 0 : getDebugName(array)}.`, suppress, {
670
- id: 'array-observers',
671
- url: 'https://deprecations.emberjs.com/v3.x#toc_array-observers',
672
- until: '4.0.0',
673
- for: 'ember-source',
674
- since: {
675
- enabled: '3.26.0-beta.1'
676
- }
677
- });
678
- return arrayObserversHelper(array, target, opts, addListener, false);
672
+ function addArrayObserver(array, target, opts) {
673
+ return arrayObserversHelper(array, target, opts, addListener);
679
674
  }
680
- function removeArrayObserver(array, target, opts, suppress = false) {
681
- deprecate(`Array observers have been deprecated. Removed an array observer from ${getDebugName === null || getDebugName === void 0 ? void 0 : getDebugName(array)}.`, suppress, {
682
- id: 'array-observers',
683
- url: 'https://deprecations.emberjs.com/v3.x#toc_array-observers',
684
- until: '4.0.0',
685
- for: 'ember-source',
686
- since: {
687
- enabled: '3.26.0-beta.1'
688
- }
689
- });
690
- return arrayObserversHelper(array, target, opts, removeListener, true);
675
+ function removeArrayObserver(array, target, opts) {
676
+ return arrayObserversHelper(array, target, opts, removeListener);
691
677
  }
692
678
 
693
679
  const CHAIN_PASS_THROUGH = new _WeakSet();
@@ -373,7 +373,7 @@ export default class RouterService extends Service {
373
373
 
374
374
  }
375
375
 
376
- if (false
376
+ if (true
377
377
  /* EMBER_ROUTING_ROUTER_SERVICE_REFRESH */
378
378
  ) {
379
379
  RouterService.reopen({
@@ -14,7 +14,6 @@ import { isProxy, lookupDescriptor, symbol } from '@ember/-internals/utils';
14
14
  import { assert, info, isTesting } from '@ember/debug';
15
15
  import { dependentKeyCompat } from '@ember/object/compat';
16
16
  import { once } from '@ember/runloop';
17
- import { classify } from '@ember/string';
18
17
  import { DEBUG } from '@glimmer/env';
19
18
  import { PARAMS_SYMBOL, STATE_SYMBOL } from 'router_js';
20
19
  import { calculateCacheKey, deprecateTransitionMethods, normalizeControllerQueryParams, prefixRouteNameArg, stashParamNames } from '../utils';
@@ -255,7 +254,8 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
255
254
 
256
255
 
257
256
  _optionsForQueryParam(qp) {
258
- return get(this, `queryParams.${qp.urlKey}`) || get(this, `queryParams.${qp.prop}`) || {};
257
+ const queryParams = get(this, 'queryParams');
258
+ return get(queryParams, qp.urlKey) || get(queryParams, qp.prop) || queryParams[qp.urlKey] || queryParams[qp.prop] || {};
259
259
  }
260
260
  /**
261
261
  A hook you can use to reset controller values either when the model
@@ -1331,18 +1331,17 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
1331
1331
  get store() {
1332
1332
  let owner = getOwner(this);
1333
1333
  let routeName = this.routeName;
1334
- let namespace = get(this, '_router.namespace');
1335
1334
  return {
1336
1335
  find(name, value) {
1337
1336
  let modelClass = owner.factoryFor(`model:${name}`);
1338
- assert(`You used the dynamic segment ${name}_id in your route ${routeName}, but ${namespace}.${classify(name)} did not exist and you did not override your route's \`model\` hook.`, Boolean(modelClass));
1337
+ assert(`You used the dynamic segment \`${name}_id\` in your route ` + `\`${routeName}\` for which Ember requires you provide a ` + `data-loading implementation. Commonly, that is done by ` + `adding a model hook implementation on the route ` + `(\`model({${name}_id}) {\`) or by injecting an implemention of ` + `a data store: \`@service store;\`.`, Boolean(modelClass));
1339
1338
 
1340
1339
  if (!modelClass) {
1341
1340
  return;
1342
1341
  }
1343
1342
 
1344
1343
  modelClass = modelClass.class;
1345
- assert(`${classify(name)} has no method \`find\`.`, typeof modelClass.find === 'function');
1344
+ assert(`You used the dynamic segment \`${name}_id\` in your route ` + `\`${routeName}\` for which Ember requires you provide a ` + `data-loading implementation. Commonly, that is done by ` + `adding a model hook implementation on the route ` + `(\`model({${name}_id}) {\`) or by injecting an implemention of ` + `a data store: \`@service store;\`.\n\n` + `Rarely, applications may attempt to use a legacy behavior where ` + `the model class (in this case \`${name}\`) is resolved and the ` + `\`find\` method on that class is invoked to load data. In this ` + `application, a model of \`${name}\` was found but it did not ` + `provide a \`find\` method. You should not add a \`find\` ` + `method to your model. Instead, please implement an appropriate ` + `\`model\` hook on the \`${routeName}\` route.`, typeof modelClass.find === 'function');
1346
1345
  return modelClass.find(value);
1347
1346
  }
1348
1347
 
@@ -4,7 +4,7 @@
4
4
  import { DEBUG } from '@glimmer/env';
5
5
  import { PROXY_CONTENT } from '@ember/-internals/metal';
6
6
  import { setEmberArray } from '@ember/-internals/utils';
7
- import { get, set, objectAt, replaceInNativeArray, replace, computed, Mixin, hasListeners, beginPropertyChanges, endPropertyChanges, addArrayObserver, removeArrayObserver, arrayContentWillChange, arrayContentDidChange, nativeDescDecorator as descriptor } from '@ember/-internals/metal';
7
+ import { get, set, objectAt, replaceInNativeArray, replace, computed, Mixin, beginPropertyChanges, endPropertyChanges } from '@ember/-internals/metal';
8
8
  import { assert } from '@ember/debug';
9
9
  import Enumerable from './enumerable';
10
10
  import compare from '../compare';
@@ -441,177 +441,6 @@ const ArrayMixin = Mixin.create(Enumerable, {
441
441
  return -1;
442
442
  },
443
443
 
444
- // ..........................................................
445
- // ARRAY OBSERVERS
446
- //
447
-
448
- /**
449
- Adds an array observer to the receiving array. The array observer object
450
- normally must implement two methods:
451
- * `willChange(observedObj, start, removeCount, addCount)` - This method will be
452
- called just before the array is modified.
453
- * `didChange(observedObj, start, removeCount, addCount)` - This method will be
454
- called just after the array is modified.
455
- Both callbacks will be passed the observed object, starting index of the
456
- change as well as a count of the items to be removed and added. You can use
457
- these callbacks to optionally inspect the array during the change, clear
458
- caches, or do any other bookkeeping necessary.
459
- In addition to passing a target, you can also include an options hash
460
- which you can use to override the method names that will be invoked on the
461
- target.
462
- @method addArrayObserver
463
- @param {Object} target The observer object.
464
- @param {Object} opts Optional hash of configuration options including
465
- `willChange` and `didChange` option.
466
- @return {EmberArray} receiver
467
- @public
468
- @example
469
- import Service from '@ember/service';
470
- export default Service.extend({
471
- data: Ember.A(),
472
- init() {
473
- this._super(...arguments);
474
- this.data.addArrayObserver(this, {
475
- willChange: 'dataWillChange',
476
- didChange: 'dataDidChange'
477
- });
478
- },
479
- dataWillChange(array, start, removeCount, addCount) {
480
- console.log('array will change', array, start, removeCount, addCount);
481
- },
482
- dataDidChange(array, start, removeCount, addCount) {
483
- console.log('array did change', array, start, removeCount, addCount);
484
- }
485
- });
486
- */
487
- addArrayObserver(target, opts) {
488
- return addArrayObserver(this, target, opts);
489
- },
490
-
491
- /**
492
- Removes an array observer from the object if the observer is current
493
- registered. Calling this method multiple times with the same object will
494
- have no effect.
495
- @method removeArrayObserver
496
- @param {Object} target The object observing the array.
497
- @param {Object} opts Optional hash of configuration options including
498
- `willChange` and `didChange` option.
499
- @return {EmberArray} receiver
500
- @public
501
- */
502
- removeArrayObserver(target, opts) {
503
- return removeArrayObserver(this, target, opts);
504
- },
505
-
506
- /**
507
- Becomes true whenever the array currently has observers watching changes
508
- on the array.
509
- ```javascript
510
- let arr = [1, 2, 3, 4, 5];
511
- arr.hasArrayObservers; // false
512
- arr.addArrayObserver(this, {
513
- willChange() {
514
- console.log('willChange');
515
- }
516
- });
517
- arr.hasArrayObservers; // true
518
- ```
519
- @property {Boolean} hasArrayObservers
520
- @public
521
- */
522
- hasArrayObservers: descriptor({
523
- configurable: true,
524
- enumerable: false,
525
-
526
- get() {
527
- return hasListeners(this, '@array:change') || hasListeners(this, '@array:before');
528
- }
529
-
530
- }),
531
-
532
- /**
533
- If you are implementing an object that supports `EmberArray`, call this
534
- method just before the array content changes to notify any observers and
535
- invalidate any related properties. Pass the starting index of the change
536
- as well as a delta of the amounts to change.
537
- ```app/components/show-post.js
538
- import Component from '@ember/component';
539
- import EmberObject from '@ember/object';
540
- const Post = EmberObject.extend({
541
- body: '',
542
- save() {}
543
- })
544
- export default Component.extend({
545
- attemptsToModify: 0,
546
- successfulModifications: 0,
547
- posts: null,
548
- init() {
549
- this._super(...arguments);
550
- this.posts = [1, 2, 3].map(i => Post.create({ body: i }));
551
- this.posts.addArrayObserver(this, {
552
- willChange() {
553
- this.incrementProperty('attemptsToModify');
554
- },
555
- didChange() {
556
- this.incrementProperty('successfulModifications');
557
- }
558
- });
559
- },
560
- actions: {
561
- editPost(post, newContent) {
562
- let oldContent = post.body,
563
- postIndex = this.posts.indexOf(post);
564
- this.posts.arrayContentWillChange(postIndex, 0, 0); // attemptsToModify = 1
565
- post.set('body', newContent);
566
- post.save()
567
- .then(response => {
568
- this.posts.arrayContentDidChange(postIndex, 0, 0); // successfulModifications = 1
569
- })
570
- .catch(error => {
571
- post.set('body', oldContent);
572
- })
573
- }
574
- }
575
- });
576
- ```
577
- @method arrayContentWillChange
578
- @param {Number} startIdx The starting index in the array that will change.
579
- @param {Number} removeAmt The number of items that will be removed. If you
580
- pass `null` assumes 0
581
- @param {Number} addAmt The number of items that will be added. If you
582
- pass `null` assumes 0.
583
- @return {EmberArray} receiver
584
- @public
585
- */
586
- arrayContentWillChange(startIdx, removeAmt, addAmt) {
587
- return arrayContentWillChange(this, startIdx, removeAmt, addAmt);
588
- },
589
-
590
- /**
591
- If you are implementing an object that supports `EmberArray`, call this
592
- method just after the array content changes to notify any observers and
593
- invalidate any related properties. Pass the starting index of the change
594
- as well as a delta of the amounts to change.
595
- ```javascript
596
- let arr = [1, 2, 3, 4, 5];
597
- arr.copyWithin(-2); // [1, 2, 3, 1, 2]
598
- // arr.lastObject = 5
599
- arr.arrayContentDidChange(3, 2, 2);
600
- // arr.lastObject = 2
601
- ```
602
- @method arrayContentDidChange
603
- @param {Number} startIdx The starting index in the array that did change.
604
- @param {Number} removeAmt The number of items that were removed. If you
605
- pass `null` assumes 0
606
- @param {Number} addAmt The number of items that were added. If you
607
- pass `null` assumes 0.
608
- @return {EmberArray} receiver
609
- @public
610
- */
611
- arrayContentDidChange(startIdx, removeAmt, addAmt) {
612
- return arrayContentDidChange(this, startIdx, removeAmt, addAmt);
613
- },
614
-
615
444
  /**
616
445
  Iterates through the array, calling the passed function on each
617
446
  item. This method corresponds to the `forEach()` method defined in
@@ -1339,7 +1168,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, {
1339
1168
  __Required.__ You must implement this method to apply this mixin.
1340
1169
  This is one of the primitives you must implement to support `Array`.
1341
1170
  You should replace amt objects started at idx with the objects in the
1342
- passed array. You should also call `this.arrayContentDidChange()`
1171
+ passed array.
1343
1172
  Note that this method is expected to validate the type(s) of objects that it expects.
1344
1173
  @method replace
1345
1174
  @param {Number} idx Starting index in the array to replace. If
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  @module @ember/array
3
3
  */
4
- import { get, objectAt, alias, PROPERTY_DID_CHANGE, addArrayObserver, removeArrayObserver, replace, arrayContentDidChange, tagForProperty } from '@ember/-internals/metal';
4
+ import { get, objectAt, alias, PROPERTY_DID_CHANGE, addArrayObserver, removeArrayObserver, replace, arrayContentDidChange, arrayContentWillChange, tagForProperty } from '@ember/-internals/metal';
5
5
  import { isObject } from '@ember/-internals/utils';
6
6
  import EmberObject from './object';
7
7
  import { isArray, MutableArray } from '../mixins/array';
@@ -237,11 +237,11 @@ export default class ArrayProxy extends EmberObject {
237
237
 
238
238
  this._removeArrangedContentArrayObserver();
239
239
 
240
- this.arrayContentWillChange(0, oldLength, newLength);
240
+ arrayContentWillChange(this, 0, oldLength, newLength);
241
241
 
242
242
  this._invalidate();
243
243
 
244
- this.arrayContentDidChange(0, oldLength, newLength);
244
+ arrayContentDidChange(this, 0, oldLength, newLength, false);
245
245
 
246
246
  this._addArrangedContentArrayObserver(arrangedContent);
247
247
  }
@@ -250,21 +250,21 @@ export default class ArrayProxy extends EmberObject {
250
250
  if (arrangedContent && !arrangedContent.isDestroyed) {
251
251
  assert("Can't set ArrayProxy's content to itself", arrangedContent !== this);
252
252
  assert(`ArrayProxy expects an Array or ArrayProxy, but you passed ${typeof arrangedContent}`, isArray(arrangedContent) || arrangedContent.isDestroyed);
253
- addArrayObserver(arrangedContent, this, ARRAY_OBSERVER_MAPPING, true);
253
+ addArrayObserver(arrangedContent, this, ARRAY_OBSERVER_MAPPING);
254
254
  this._arrangedContent = arrangedContent;
255
255
  }
256
256
  }
257
257
 
258
258
  _removeArrangedContentArrayObserver() {
259
259
  if (this._arrangedContent) {
260
- removeArrayObserver(this._arrangedContent, this, ARRAY_OBSERVER_MAPPING, true);
260
+ removeArrayObserver(this._arrangedContent, this, ARRAY_OBSERVER_MAPPING);
261
261
  }
262
262
  }
263
263
 
264
264
  _arrangedContentArrayWillChange() {}
265
265
 
266
266
  _arrangedContentArrayDidChange(proxy, idx, removedCnt, addedCnt) {
267
- this.arrayContentWillChange(idx, removedCnt, addedCnt);
267
+ arrayContentWillChange(this, idx, removedCnt, addedCnt);
268
268
  let dirtyIndex = idx;
269
269
 
270
270
  if (dirtyIndex < 0) {
@@ -277,7 +277,7 @@ export default class ArrayProxy extends EmberObject {
277
277
  }
278
278
 
279
279
  this._lengthDirty = true;
280
- this.arrayContentDidChange(idx, removedCnt, addedCnt);
280
+ arrayContentDidChange(this, idx, removedCnt, addedCnt, false);
281
281
  }
282
282
 
283
283
  _invalidate() {
@@ -324,12 +324,5 @@ ArrayProxy.reopen(MutableArray, {
324
324
  @property arrangedContent
325
325
  @public
326
326
  */
327
- arrangedContent: alias('content'),
328
-
329
- // Array proxies don't need to notify when they change since their `[]` tag is
330
- // already dependent on the `[]` tag of `arrangedContent`
331
- arrayContentDidChange(startIdx, removeAmt, addAmt) {
332
- return arrayContentDidChange(this, startIdx, removeAmt, addAmt, false);
333
- }
334
-
327
+ arrangedContent: alias('content')
335
328
  });
@@ -18,7 +18,7 @@ export const DEFAULT_FEATURES = {
18
18
  EMBER_GLIMMER_INVOKE_HELPER: true,
19
19
  EMBER_STRICT_MODE: true,
20
20
  EMBER_DYNAMIC_HELPERS_AND_MODIFIERS: true,
21
- EMBER_ROUTING_ROUTER_SERVICE_REFRESH: null,
21
+ EMBER_ROUTING_ROUTER_SERVICE_REFRESH: true,
22
22
  EMBER_CACHED: true
23
23
  };
24
24
  /**
@@ -22,7 +22,9 @@ import { registerDestructor as _registerDestructor, unregisterDestructor as _unr
22
22
 
23
23
  ```js
24
24
  class CustomSelect extends Component {
25
- constructor() {
25
+ constructor(...args) {
26
+ super(...args);
27
+
26
28
  // obj is now a child of the component. When the component is destroyed,
27
29
  // obj will also be destroyed, and have all of its destructors triggered.
28
30
  this.obj = associateDestroyableChild(this, {});
@@ -153,12 +155,15 @@ import { registerDestructor as _registerDestructor, unregisterDestructor as _unr
153
155
  parent is destroyed, the destructor function will be called.
154
156
 
155
157
  ```js
158
+ import Component from '@glimmer/component';
156
159
  import { registerDestructor } from '@ember/destroyable';
157
160
 
158
161
  class Modal extends Component {
159
162
  @service resize;
160
163
 
161
- constructor() {
164
+ constructor(...args) {
165
+ super(...args);
166
+
162
167
  this.resize.register(this, this.layout);
163
168
 
164
169
  registerDestructor(this, () => this.resize.unregister(this));
@@ -175,6 +180,7 @@ import { registerDestructor as _registerDestructor, unregisterDestructor as _unr
175
180
  than creating a closure function per destroyable.
176
181
 
177
182
  ```js
183
+ import Component from '@glimmer/component';
178
184
  import { registerDestructor } from '@ember/destroyable';
179
185
 
180
186
  function unregisterResize(instance) {
@@ -184,7 +190,9 @@ import { registerDestructor as _registerDestructor, unregisterDestructor as _unr
184
190
  class Modal extends Component {
185
191
  @service resize;
186
192
 
187
- constructor() {
193
+ constructor(...args) {
194
+ super(...args);
195
+
188
196
  this.resize.register(this, this.layout);
189
197
 
190
198
  registerDestructor(this, unregisterResize);
@@ -208,12 +216,15 @@ export function registerDestructor(destroyable, destructor) {
208
216
  from the destroyable.
209
217
 
210
218
  ```js
219
+ import Component from '@glimmer/component';
211
220
  import { registerDestructor, unregisterDestructor } from '@ember/destroyable';
212
221
 
213
222
  class Modal extends Component {
214
223
  @service modals;
215
224
 
216
- constructor() {
225
+ constructor(...args) {
226
+ super(...args);
227
+
217
228
  this.modals.add(this);
218
229
 
219
230
  this.modalDestructor = registerDestructor(this, () => this.modals.remove(this));
@@ -1 +1 @@
1
- export default "4.1.0-alpha.7";
1
+ export default "4.2.0-alpha.2";