ember-source 4.1.0-alpha.6 → 4.1.0
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.
- package/CHANGELOG.md +80 -63
- package/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/helper-test/index.js +4 -22
- package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +1 -13
- package/blueprints/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +0 -13
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -12
- package/blueprints/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +2 -13
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -14
- package/build-metadata.json +3 -3
- package/dist/dependencies/@glimmer/manager.js +19 -98
- package/dist/dependencies/@glimmer/opcode-compiler.js +9 -146
- package/dist/dependencies/@glimmer/runtime.js +1 -55
- package/dist/dependencies/@glimmer/validator.js +19 -51
- package/dist/ember-template-compiler.js +368 -693
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +1 -1
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3261 -6351
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/environment/index.js +0 -15
- package/dist/packages/@ember/-internals/glimmer/index.js +4815 -6763
- package/dist/packages/@ember/-internals/metal/index.js +57 -103
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +10 -1
- package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +7 -2
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +1 -1
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +1 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +3 -42
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +36 -46
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +2 -173
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +3 -43
- package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +8 -15
- package/dist/packages/@ember/-internals/utils/index.js +0 -3
- package/dist/packages/@ember/-internals/views/index.js +0 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -4
- package/dist/packages/@ember/application/lib/application.js +7 -8
- package/dist/packages/@ember/canary-features/index.js +4 -6
- package/dist/packages/@ember/component/index.js +1 -1
- package/dist/packages/@ember/deprecated-features/index.js +0 -1
- package/dist/packages/@ember/destroyable/index.js +15 -4
- package/dist/packages/@ember/engine/index.js +1 -2
- package/dist/packages/@ember/routing/index.js +1 -1
- package/dist/packages/@glimmer/tracking/index.js +203 -1
- package/dist/packages/ember/index.js +9 -61
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +430 -1382
- package/lib/browsers.js +50 -0
- package/lib/index.js +7 -29
- package/package.json +19 -22
- package/dist/packages/@ember/-internals/views/lib/mixins/text_support.js +0 -345
- package/dist/packages/@ember/component/checkbox.js +0 -17
- package/dist/packages/@ember/component/text-area.js +0 -17
- package/dist/packages/@ember/component/text-field.js +0 -17
- package/dist/packages/@ember/routing/link-component.js +0 -17
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { meta, peekMeta } from '@ember/-internals/meta';
|
|
2
|
-
import { setListeners, isObject, setupMandatorySetter, symbol, toString, enumerableSymbol,
|
|
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';
|
|
6
6
|
import { registerDestructor, isDestroyed } from '@glimmer/destroyable';
|
|
7
|
-
import { CURRENT_TAG, tagMetaFor, validateTag, valueForTag, CONSTANT_TAG, dirtyTagFor, tagFor, combine, createUpdatableTag, updateTag, ALLOW_CYCLES, consumeTag, track, untrack,
|
|
7
|
+
import { CURRENT_TAG, tagMetaFor, validateTag, valueForTag, CONSTANT_TAG, dirtyTagFor, tagFor, combine, createUpdatableTag, updateTag, ALLOW_CYCLES, consumeTag, track, untrack, isTracking, trackedData, createCache, getValue } from '@glimmer/validator';
|
|
8
8
|
export { createCache, getValue, isConst } from '@glimmer/validator';
|
|
9
9
|
import { DEBUG } from '@glimmer/env';
|
|
10
10
|
import { getCustomTagFor } from '@glimmer/manager';
|
|
@@ -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
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
let
|
|
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
|
-
|
|
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
|
|
669
|
-
|
|
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
|
|
681
|
-
|
|
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();
|
|
@@ -1842,13 +1828,7 @@ function _getProp(obj, keyName) {
|
|
|
1842
1828
|
}
|
|
1843
1829
|
|
|
1844
1830
|
if (value === undefined && isObject$$1 && !(keyName in obj) && typeof obj.unknownProperty === 'function') {
|
|
1845
|
-
|
|
1846
|
-
deprecateMutationsInTrackingTransaction(() => {
|
|
1847
|
-
value = obj.unknownProperty(keyName);
|
|
1848
|
-
});
|
|
1849
|
-
} else {
|
|
1850
|
-
value = obj.unknownProperty(keyName);
|
|
1851
|
-
}
|
|
1831
|
+
value = obj.unknownProperty(keyName);
|
|
1852
1832
|
}
|
|
1853
1833
|
|
|
1854
1834
|
if (isTracking()) {
|
|
@@ -3115,9 +3095,7 @@ class Mixin {
|
|
|
3115
3095
|
|
|
3116
3096
|
guidFor(this);
|
|
3117
3097
|
|
|
3118
|
-
if (true
|
|
3119
|
-
/* EMBER_MODERNIZED_BUILT_IN_COMPONENTS */
|
|
3120
|
-
&& Mixin._disableDebugSeal !== true) {
|
|
3098
|
+
if (Mixin._disableDebugSeal !== true) {
|
|
3121
3099
|
Object.seal(this);
|
|
3122
3100
|
}
|
|
3123
3101
|
}
|
|
@@ -3240,9 +3218,7 @@ class Mixin {
|
|
|
3240
3218
|
|
|
3241
3219
|
}
|
|
3242
3220
|
|
|
3243
|
-
if (DEBUG
|
|
3244
|
-
/* EMBER_MODERNIZED_BUILT_IN_COMPONENTS */
|
|
3245
|
-
) {
|
|
3221
|
+
if (DEBUG) {
|
|
3246
3222
|
Object.defineProperty(Mixin, '_disableDebugSeal', {
|
|
3247
3223
|
configurable: true,
|
|
3248
3224
|
enumerable: false,
|
|
@@ -3479,68 +3455,46 @@ class TrackedDescriptor {
|
|
|
3479
3455
|
}
|
|
3480
3456
|
|
|
3481
3457
|
// NOTE: copied from: https://github.com/glimmerjs/glimmer.js/pull/358
|
|
3482
|
-
/**
|
|
3483
|
-
* @decorator
|
|
3484
|
-
*
|
|
3485
|
-
* The `@cached` decorator can be used on getters in order to cache the return
|
|
3486
|
-
* value of the getter. This is useful when a getter is expensive and used very
|
|
3487
|
-
* often.
|
|
3488
|
-
*
|
|
3489
|
-
*
|
|
3490
|
-
* @example
|
|
3491
|
-
*
|
|
3492
|
-
* in this guest list class, we have the `sortedGuests`
|
|
3493
|
-
* getter that sorts the guests alphabetically:
|
|
3494
|
-
*
|
|
3495
|
-
* ```js
|
|
3496
|
-
* import { tracked } from '@glimmer/tracking';
|
|
3497
|
-
*
|
|
3498
|
-
* class GuestList {
|
|
3499
|
-
* @tracked guests = ['Zoey', 'Tomster'];
|
|
3500
|
-
*
|
|
3501
|
-
* get sortedGuests() {
|
|
3502
|
-
* return this.guests.slice().sort()
|
|
3503
|
-
* }
|
|
3504
|
-
* }
|
|
3505
|
-
* ```
|
|
3506
|
-
*
|
|
3507
|
-
* Every time `sortedGuests` is accessed, a new array will be created and sorted,
|
|
3508
|
-
* because JavaScript getters do not cache by default. When the guest list is
|
|
3509
|
-
* small, like the one in the example, this is not a problem. However, if the guest
|
|
3510
|
-
* list were to grow very large, it would mean that we would be doing a large
|
|
3511
|
-
* amount of work each time we accessed `sortedGetters`. With `@cached`, we can
|
|
3512
|
-
* cache the value instead:
|
|
3513
|
-
*
|
|
3514
|
-
* ```js
|
|
3515
|
-
* import { tracked, cached } from '@glimmer/tracking';
|
|
3516
|
-
*
|
|
3517
|
-
* class GuestList {
|
|
3518
|
-
* @tracked guests = ['Zoey', 'Tomster'];
|
|
3519
|
-
*
|
|
3520
|
-
* @cached
|
|
3521
|
-
* get sortedGuests() {
|
|
3522
|
-
* return this.guests.slice().sort()
|
|
3523
|
-
* }
|
|
3524
|
-
* }
|
|
3525
|
-
* ```
|
|
3526
|
-
*
|
|
3527
|
-
* Now the `sortedGuests` getter will be cached based on _autotracking_. It will
|
|
3528
|
-
* only rerun and create a new sorted array when the `guests` tracked property is
|
|
3529
|
-
* updated.
|
|
3530
|
-
*
|
|
3531
|
-
* In general, you should avoid using `@cached` unless you have confirmed that the
|
|
3532
|
-
* getter you are decorating is computationally expensive. `@cached` adds a small
|
|
3533
|
-
* amount of overhead to the getter, making it more expensive. While this overhead
|
|
3534
|
-
* is small, if `@cached` is overused it can add up to a large impact overall in
|
|
3535
|
-
* your app. Many getters and tracked properties are only accessed once, rendered,
|
|
3536
|
-
* and then never rerendered, so adding `@cached` when it is unnecessary can
|
|
3537
|
-
* negatively impact performance.
|
|
3538
|
-
*/
|
|
3539
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3540
3458
|
|
|
3541
3459
|
const cached = (...args) => {
|
|
3460
|
+
{
|
|
3461
|
+
const [target, key, descriptor] = args; // Error on `@cached()`, `@cached(...args)`, and `@cached propName = value;`
|
|
3462
|
+
|
|
3463
|
+
if (DEBUG && target === undefined) throwCachedExtraneousParens();
|
|
3464
|
+
|
|
3465
|
+
if (DEBUG && (typeof target !== 'object' || typeof key !== 'string' || typeof descriptor !== 'object' || args.length !== 3)) {
|
|
3466
|
+
throwCachedInvalidArgsError(args);
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3469
|
+
if (DEBUG && (!('get' in descriptor) || typeof descriptor.get !== 'function')) {
|
|
3470
|
+
throwCachedGetterOnlyError(key);
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
const caches = new WeakMap();
|
|
3474
|
+
const getter = descriptor.get;
|
|
3475
|
+
|
|
3476
|
+
descriptor.get = function () {
|
|
3477
|
+
if (!caches.has(this)) {
|
|
3478
|
+
caches.set(this, createCache(getter.bind(this)));
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
return getValue(caches.get(this));
|
|
3482
|
+
};
|
|
3483
|
+
}
|
|
3542
3484
|
};
|
|
3543
3485
|
|
|
3486
|
+
function throwCachedExtraneousParens() {
|
|
3487
|
+
throw new Error('You attempted to use @cached(), which is not necessary nor supported. Remove the parentheses and you will be good to go!');
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
function throwCachedGetterOnlyError(key) {
|
|
3491
|
+
throw new Error(`The @cached decorator must be applied to getters. '${key}' is not a getter.`);
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3494
|
+
function throwCachedInvalidArgsError(args = []) {
|
|
3495
|
+
throw new Error(`You attempted to use @cached on with ${args.length > 1 ? 'arguments' : 'an argument'} ( @cached(${args.map(d => `'${d}'`).join(', ')}), which is not supported. Dependencies are automatically tracked, so you can just use ${'`@cached`'}`);
|
|
3496
|
+
}
|
|
3497
|
+
|
|
3544
3498
|
/**
|
|
3545
3499
|
Ember uses caching based on trackable values to avoid updating large portions
|
|
3546
3500
|
of the application. This caching is exposed via a cache primitive that can be
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assert } from '@ember/debug';
|
|
1
|
+
import { assert, deprecate } from '@ember/debug';
|
|
2
2
|
/**
|
|
3
3
|
@module @ember/routing
|
|
4
4
|
*/
|
|
@@ -87,6 +87,15 @@ export default {
|
|
|
87
87
|
assert("Location.create: you must specify a 'implementation' option", Boolean(implementation));
|
|
88
88
|
let implementationClass = this.implementations[implementation];
|
|
89
89
|
assert(`Location.create: ${implementation} is not a valid implementation`, Boolean(implementationClass));
|
|
90
|
+
deprecate("Calling `create` on Location class is deprecated. Instead, use `container.lookup('location:my-location')` to lookup the location you need.", false, {
|
|
91
|
+
id: 'deprecate-auto-location',
|
|
92
|
+
until: '5.0.0',
|
|
93
|
+
url: 'https://emberjs.com/deprecations/v4.x#toc_deprecate-auto-location',
|
|
94
|
+
for: 'ember-source',
|
|
95
|
+
since: {
|
|
96
|
+
enabled: '4.1.0'
|
|
97
|
+
}
|
|
98
|
+
});
|
|
90
99
|
return implementationClass.create(...arguments);
|
|
91
100
|
},
|
|
92
101
|
|
|
@@ -26,10 +26,15 @@ export default class NoneLocation extends EmberObject {
|
|
|
26
26
|
this.implementation = 'none';
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
initState() {
|
|
30
|
+
this._super(...arguments);
|
|
31
|
+
|
|
30
32
|
let {
|
|
31
33
|
rootURL
|
|
32
|
-
} = this;
|
|
34
|
+
} = this; // This assert doesn't have anything to do with state initialization,
|
|
35
|
+
// but we're hijacking this method since it's called after the route has
|
|
36
|
+
// set the rootURL property on its Location instance.
|
|
37
|
+
|
|
33
38
|
assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/');
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
@@ -7,7 +7,7 @@ import { readOnly } from '@ember/object/computed';
|
|
|
7
7
|
import Service from '@ember/service';
|
|
8
8
|
const ROUTER = symbol('ROUTER');
|
|
9
9
|
/**
|
|
10
|
-
The Routing service is used by
|
|
10
|
+
The Routing service is used by LinkTo, and provides facilities for
|
|
11
11
|
the component/view layer to interact with the router.
|
|
12
12
|
|
|
13
13
|
This is a private service for internal usage only. For public usage,
|
|
@@ -11,8 +11,7 @@ import { addObserver, computed, defineProperty, descriptorForProperty, flushAsyn
|
|
|
11
11
|
import { getOwner } from '@ember/-internals/owner';
|
|
12
12
|
import { A as emberA, ActionHandler, Evented, Object as EmberObject, typeOf } from '@ember/-internals/runtime';
|
|
13
13
|
import { isProxy, lookupDescriptor, symbol } from '@ember/-internals/utils';
|
|
14
|
-
import { assert,
|
|
15
|
-
import { ROUTER_EVENTS } from '@ember/deprecated-features';
|
|
14
|
+
import { assert, info, isTesting } from '@ember/debug';
|
|
16
15
|
import { dependentKeyCompat } from '@ember/object/compat';
|
|
17
16
|
import { once } from '@ember/runloop';
|
|
18
17
|
import { classify } from '@ember/string';
|
|
@@ -256,7 +255,8 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
256
255
|
|
|
257
256
|
|
|
258
257
|
_optionsForQueryParam(qp) {
|
|
259
|
-
|
|
258
|
+
const queryParams = get(this, 'queryParams');
|
|
259
|
+
return get(queryParams, qp.urlKey) || get(queryParams, qp.prop) || queryParams[qp.urlKey] || queryParams[qp.prop] || {};
|
|
260
260
|
}
|
|
261
261
|
/**
|
|
262
262
|
A hook you can use to reset controller values either when the model
|
|
@@ -1946,43 +1946,4 @@ Route.reopen({
|
|
|
1946
1946
|
|
|
1947
1947
|
}
|
|
1948
1948
|
});
|
|
1949
|
-
export let ROUTER_EVENT_DEPRECATIONS;
|
|
1950
|
-
|
|
1951
|
-
if (ROUTER_EVENTS) {
|
|
1952
|
-
ROUTER_EVENT_DEPRECATIONS = {
|
|
1953
|
-
on(name) {
|
|
1954
|
-
this._super(...arguments);
|
|
1955
|
-
|
|
1956
|
-
let hasDidTransition = name === 'didTransition';
|
|
1957
|
-
let hasWillTransition = name === 'willTransition';
|
|
1958
|
-
|
|
1959
|
-
if (hasDidTransition) {
|
|
1960
|
-
deprecate('You attempted to listen to the "didTransition" event which is deprecated. Please inject the router service and listen to the "routeDidChange" event.', false, {
|
|
1961
|
-
id: 'deprecate-router-events',
|
|
1962
|
-
until: '4.0.0',
|
|
1963
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_deprecate-router-events',
|
|
1964
|
-
for: 'ember-source',
|
|
1965
|
-
since: {
|
|
1966
|
-
enabled: '3.11.0'
|
|
1967
|
-
}
|
|
1968
|
-
});
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
if (hasWillTransition) {
|
|
1972
|
-
deprecate('You attempted to listen to the "willTransition" event which is deprecated. Please inject the router service and listen to the "routeWillChange" event.', false, {
|
|
1973
|
-
id: 'deprecate-router-events',
|
|
1974
|
-
until: '4.0.0',
|
|
1975
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_deprecate-router-events',
|
|
1976
|
-
for: 'ember-source',
|
|
1977
|
-
since: {
|
|
1978
|
-
enabled: '3.11.0'
|
|
1979
|
-
}
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
};
|
|
1985
|
-
Route.reopen(ROUTER_EVENT_DEPRECATIONS);
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
1949
|
export default Route;
|
|
@@ -3,14 +3,13 @@ import { computed, get, set } from '@ember/-internals/metal';
|
|
|
3
3
|
import { getOwner } from '@ember/-internals/owner';
|
|
4
4
|
import { A as emberA, Evented, Object as EmberObject, typeOf } from '@ember/-internals/runtime';
|
|
5
5
|
import { assert, deprecate, info } from '@ember/debug';
|
|
6
|
-
import { ROUTER_EVENTS } from '@ember/deprecated-features';
|
|
7
6
|
import EmberError from '@ember/error';
|
|
8
7
|
import { cancel, once, run, scheduleOnce } from '@ember/runloop';
|
|
9
8
|
import { DEBUG } from '@glimmer/env';
|
|
10
9
|
import EmberLocation from '../location/api';
|
|
11
10
|
import { calculateCacheKey, extractRouteArgs, getActiveTargetName, resemblesURL } from '../utils';
|
|
12
11
|
import DSL from './dsl';
|
|
13
|
-
import { defaultSerialize, getFullQueryParams, hasDefaultSerialize, ROUTE_CONNECTIONS
|
|
12
|
+
import { defaultSerialize, getFullQueryParams, hasDefaultSerialize, ROUTE_CONNECTIONS } from './route';
|
|
14
13
|
import RouterState from './router_state';
|
|
15
14
|
import Router, { logAbort, STATE_SYMBOL } from 'router_js';
|
|
16
15
|
|
|
@@ -20,10 +19,7 @@ function defaultDidTransition(infos) {
|
|
|
20
19
|
this._cancelSlowTransitionTimer();
|
|
21
20
|
|
|
22
21
|
this.notifyPropertyChange('url');
|
|
23
|
-
this.set('currentState', this.targetState);
|
|
24
|
-
// less surprising than didTransition being out of sync.
|
|
25
|
-
|
|
26
|
-
once(this, this.trigger, 'didTransition');
|
|
22
|
+
this.set('currentState', this.targetState);
|
|
27
23
|
|
|
28
24
|
if (DEBUG) {
|
|
29
25
|
// @ts-expect-error namespace isn't public
|
|
@@ -34,9 +30,7 @@ function defaultDidTransition(infos) {
|
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
function defaultWillTransition(oldInfos, newInfos
|
|
38
|
-
once(this, this.trigger, 'willTransition', transition);
|
|
39
|
-
|
|
33
|
+
function defaultWillTransition(oldInfos, newInfos) {
|
|
40
34
|
if (DEBUG) {
|
|
41
35
|
// @ts-expect-error namespace isn't public
|
|
42
36
|
if (this.namespace.LOG_TRANSITIONS) {
|
|
@@ -256,42 +250,18 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
256
250
|
location.setURL(path);
|
|
257
251
|
set(router, 'currentURL', path);
|
|
258
252
|
});
|
|
259
|
-
}
|
|
253
|
+
} // TODO: merge into routeDidChange
|
|
260
254
|
|
|
261
|
-
didTransition(infos) {
|
|
262
|
-
if (ROUTER_EVENTS) {
|
|
263
|
-
if (router.didTransition !== defaultDidTransition) {
|
|
264
|
-
deprecate('You attempted to override the "didTransition" method which is deprecated. Please inject the router service and listen to the "routeDidChange" event.', false, {
|
|
265
|
-
id: 'deprecate-router-events',
|
|
266
|
-
until: '4.0.0',
|
|
267
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_deprecate-router-events',
|
|
268
|
-
for: 'ember-source',
|
|
269
|
-
since: {
|
|
270
|
-
enabled: '3.11.0'
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
255
|
|
|
256
|
+
didTransition(infos) {
|
|
257
|
+
assert('You attempted to override the "didTransition" method which has been deprecated. Please inject the router service and listen to the "routeDidChange" event.', router.didTransition === defaultDidTransition);
|
|
276
258
|
router.didTransition(infos);
|
|
277
|
-
}
|
|
259
|
+
} // TODO: merge into routeWillChange
|
|
278
260
|
|
|
279
|
-
willTransition(oldInfos, newInfos, transition) {
|
|
280
|
-
if (ROUTER_EVENTS) {
|
|
281
|
-
if (router.willTransition !== defaultWillTransition) {
|
|
282
|
-
deprecate('You attempted to override the "willTransition" method which is deprecated. Please inject the router service and listen to the "routeWillChange" event.', false, {
|
|
283
|
-
id: 'deprecate-router-events',
|
|
284
|
-
until: '4.0.0',
|
|
285
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_deprecate-router-events',
|
|
286
|
-
for: 'ember-source',
|
|
287
|
-
since: {
|
|
288
|
-
enabled: '3.11.0'
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
261
|
|
|
294
|
-
|
|
262
|
+
willTransition(oldInfos, newInfos) {
|
|
263
|
+
assert('You attempted to override the "willTransition" method which has been deprecated. Please inject the router service and listen to the "routeWillChange" event.', router.willTransition === defaultWillTransition);
|
|
264
|
+
router.willTransition(oldInfos, newInfos);
|
|
295
265
|
}
|
|
296
266
|
|
|
297
267
|
triggerEvent(routeInfos, ignoreFailure, name, args) {
|
|
@@ -752,6 +722,18 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
752
722
|
if ('string' === typeof location) {
|
|
753
723
|
let resolvedLocation = owner.lookup(`location:${location}`);
|
|
754
724
|
|
|
725
|
+
if (location === 'auto') {
|
|
726
|
+
deprecate("Router location 'auto' is deprecated. Most users will want to set `locationType` to 'history' in config/environment.js for no change in behavior. See deprecation docs for details.", false, {
|
|
727
|
+
id: 'deprecate-auto-location',
|
|
728
|
+
until: '5.0.0',
|
|
729
|
+
url: 'https://emberjs.com/deprecations/v4.x#toc_deprecate-auto-location',
|
|
730
|
+
for: 'ember-source',
|
|
731
|
+
since: {
|
|
732
|
+
enabled: '4.1.0'
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
|
|
755
737
|
if (resolvedLocation !== undefined) {
|
|
756
738
|
location = set(this, 'location', resolvedLocation);
|
|
757
739
|
} else {
|
|
@@ -772,6 +754,18 @@ class EmberRouter extends EmberObject.extend(Evented) {
|
|
|
772
754
|
|
|
773
755
|
|
|
774
756
|
if (typeof location.detect === 'function') {
|
|
757
|
+
if (this.location !== 'auto') {
|
|
758
|
+
deprecate('The `detect` method on the Location object is deprecated. If you need detection you can run your detection code in app.js, before setting the location type.', false, {
|
|
759
|
+
id: 'deprecate-auto-location',
|
|
760
|
+
until: '5.0.0',
|
|
761
|
+
url: 'https://emberjs.com/deprecations/v4.x#toc_deprecate-auto-location',
|
|
762
|
+
for: 'ember-source',
|
|
763
|
+
since: {
|
|
764
|
+
enabled: '4.1.0'
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
|
|
775
769
|
location.detect();
|
|
776
770
|
} // ensure that initState is called AFTER the rootURL is set on
|
|
777
771
|
// the location instance
|
|
@@ -1415,7 +1409,8 @@ export function triggerEvent(routeInfos, ignoreFailure, name, args) {
|
|
|
1415
1409
|
if (!routeInfos) {
|
|
1416
1410
|
if (ignoreFailure) {
|
|
1417
1411
|
return;
|
|
1418
|
-
}
|
|
1412
|
+
} // TODO: update?
|
|
1413
|
+
|
|
1419
1414
|
|
|
1420
1415
|
throw new EmberError(`Can't trigger action '${name}' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call \`.send()\` on the \`Transition\` object passed to the \`model/beforeModel/afterModel\` hooks.`);
|
|
1421
1416
|
}
|
|
@@ -1624,9 +1619,4 @@ EmberRouter.reopen({
|
|
|
1624
1619
|
return location.getURL();
|
|
1625
1620
|
})
|
|
1626
1621
|
});
|
|
1627
|
-
|
|
1628
|
-
if (ROUTER_EVENTS) {
|
|
1629
|
-
EmberRouter.reopen(ROUTER_EVENT_DEPRECATIONS);
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
1622
|
export default EmberRouter;
|
|
@@ -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,
|
|
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.
|
|
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
|