ember-source 4.2.0-beta.1 → 4.3.0-alpha.4
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/blueprints/component-addon/index.js +2 -3
- package/blueprints/component-class-addon/index.js +2 -3
- package/blueprints/controller/files/__root__/__path__/__name__.js +2 -2
- package/blueprints/controller/index.js +2 -4
- package/blueprints/route/files/__root__/__path__/__name__.js +3 -3
- package/blueprints/route/index.js +2 -3
- package/blueprints/service/files/__root__/__path__/__name__.js +2 -2
- package/blueprints/service/index.js +2 -4
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +1238 -852
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +88 -56
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3211 -2123
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/header/loader.js +0 -1
- package/dist/packages/@ember/-internals/bootstrap/index.js +0 -2
- package/dist/packages/@ember/-internals/container/index.js +2 -1
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +3 -3
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +52 -52
- package/dist/packages/@ember/-internals/glimmer/index.js +101 -80
- package/dist/packages/@ember/-internals/meta/lib/meta.js +59 -2
- package/dist/packages/@ember/-internals/metal/index.js +51 -76
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +14 -4
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +1 -0
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +7 -49
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +57 -33
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +22 -7
- package/dist/packages/@ember/-internals/routing/lib/utils.js +23 -11
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -32
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -0
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +4 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +29 -29
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +16 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +48 -48
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +8 -8
- package/dist/packages/@ember/-internals/runtime/lib/system/namespace.js +1 -2
- package/dist/packages/@ember/-internals/runtime/lib/type-of.js +1 -1
- package/dist/packages/@ember/-internals/utils/index.js +9 -9
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +2 -4
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -0
- package/dist/packages/@ember/application/lib/application.js +0 -2
- package/dist/packages/@ember/array/index.js +1 -1
- package/dist/packages/@ember/canary-features/index.js +2 -2
- package/dist/packages/@ember/debug/index.js +1 -1
- package/dist/packages/@ember/debug/lib/deprecate.js +12 -10
- package/dist/packages/@ember/object/compat.js +16 -7
- package/dist/packages/@ember/polyfills/lib/assign.js +1 -0
- package/dist/packages/@ember/runloop/index.js +9 -9
- package/dist/packages/@ember/string/index.js +1 -0
- package/dist/packages/ember/index.js +1 -2
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +1362 -681
- package/package.json +31 -31
- package/blueprints/component-addon/native-files/__root__/__path__/__name__.js +0 -1
- package/blueprints/component-class-addon/native-files/__root__/__path__/__name__.js +0 -1
- package/blueprints/controller/native-files/__root__/__path__/__name__.js +0 -4
- package/blueprints/edition-detector.js +0 -13
- package/blueprints/route/native-files/__root__/__path__/__name__.js +0 -11
- package/blueprints/route/native-files/__root__/__templatepath__/__templatename__.hbs +0 -2
- package/blueprints/service/native-files/__root__/__path__/__name__.js +0 -4
|
@@ -759,7 +759,6 @@ function getChainTags(chainTags, obj, path, tagMeta, meta$$1) {
|
|
|
759
759
|
descriptor = currentMeta !== null ? currentMeta.peekDescriptors(segment) : undefined; // If the key is an alias, we need to bootstrap it
|
|
760
760
|
|
|
761
761
|
if (descriptor !== undefined && typeof descriptor.altKey === 'string') {
|
|
762
|
-
// tslint:disable-next-line: no-unused-expression
|
|
763
762
|
item[segment];
|
|
764
763
|
}
|
|
765
764
|
}
|
|
@@ -781,7 +780,6 @@ function getChainTags(chainTags, obj, path, tagMeta, meta$$1) {
|
|
|
781
780
|
// bootstrap the alias. This is because aliases, unlike other CPs, should
|
|
782
781
|
// always be in sync with the aliased value.
|
|
783
782
|
if (CHAIN_PASS_THROUGH.has(descriptor)) {
|
|
784
|
-
// tslint:disable-next-line: no-unused-expression
|
|
785
783
|
current[segment];
|
|
786
784
|
}
|
|
787
785
|
|
|
@@ -1585,11 +1583,15 @@ class ComputedDecoratorImpl extends Function {
|
|
|
1585
1583
|
} // TODO: Remove this when we can provide alternatives in the ecosystem to
|
|
1586
1584
|
// addons such as ember-macro-helpers that use it.
|
|
1587
1585
|
|
|
1586
|
+
/** @internal */
|
|
1587
|
+
|
|
1588
1588
|
|
|
1589
1589
|
get _getter() {
|
|
1590
1590
|
return descriptorForDecorator(this)._getter;
|
|
1591
1591
|
} // TODO: Refactor this, this is an internal API only
|
|
1592
1592
|
|
|
1593
|
+
/** @internal */
|
|
1594
|
+
|
|
1593
1595
|
|
|
1594
1596
|
set enumerable(value) {
|
|
1595
1597
|
descriptorForDecorator(this).enumerable = value;
|
|
@@ -1633,6 +1635,8 @@ function getCachedValueFor(obj, key) {
|
|
|
1633
1635
|
|
|
1634
1636
|
if (meta$$1) {
|
|
1635
1637
|
return meta$$1.valueFor(key);
|
|
1638
|
+
} else {
|
|
1639
|
+
return undefined;
|
|
1636
1640
|
}
|
|
1637
1641
|
}
|
|
1638
1642
|
|
|
@@ -1766,45 +1770,7 @@ if (DEBUG) {
|
|
|
1766
1770
|
return Reflect.get(content, keyName, obj);
|
|
1767
1771
|
}
|
|
1768
1772
|
};
|
|
1769
|
-
}
|
|
1770
|
-
// GET AND SET
|
|
1771
|
-
//
|
|
1772
|
-
// If we are on a platform that supports accessors we can use those.
|
|
1773
|
-
// Otherwise simulate accessors by looking up the property directly on the
|
|
1774
|
-
// object.
|
|
1775
|
-
|
|
1776
|
-
/**
|
|
1777
|
-
Gets the value of a property on an object. If the property is computed,
|
|
1778
|
-
the function will be invoked. If the property is not defined but the
|
|
1779
|
-
object implements the `unknownProperty` method then that will be invoked.
|
|
1780
|
-
|
|
1781
|
-
```javascript
|
|
1782
|
-
import { get } from '@ember/object';
|
|
1783
|
-
get(obj, "name");
|
|
1784
|
-
```
|
|
1785
|
-
|
|
1786
|
-
If you plan to run on IE8 and older browsers then you should use this
|
|
1787
|
-
method anytime you want to retrieve a property on an object that you don't
|
|
1788
|
-
know for sure is private. (Properties beginning with an underscore '_'
|
|
1789
|
-
are considered private.)
|
|
1790
|
-
|
|
1791
|
-
On all newer browsers, you only need to use this method to retrieve
|
|
1792
|
-
properties if the property might not be defined on the object and you want
|
|
1793
|
-
to respect the `unknownProperty` handler. Otherwise you can ignore this
|
|
1794
|
-
method.
|
|
1795
|
-
|
|
1796
|
-
Note that if the object itself is `undefined`, this method will throw
|
|
1797
|
-
an error.
|
|
1798
|
-
|
|
1799
|
-
@method get
|
|
1800
|
-
@for @ember/object
|
|
1801
|
-
@static
|
|
1802
|
-
@param {Object} obj The object to retrieve from.
|
|
1803
|
-
@param {String} keyName The property key to retrieve
|
|
1804
|
-
@return {Object} the property value or `null`.
|
|
1805
|
-
@public
|
|
1806
|
-
*/
|
|
1807
|
-
|
|
1773
|
+
}
|
|
1808
1774
|
|
|
1809
1775
|
function get(obj, keyName) {
|
|
1810
1776
|
assert(`Get must be called with two arguments; an object and a property key`, arguments.length === 2);
|
|
@@ -2083,7 +2049,6 @@ class AliasedProperty extends ComputedDescriptor {
|
|
|
2083
2049
|
}
|
|
2084
2050
|
|
|
2085
2051
|
function AliasedProperty_readOnlySet(obj, keyName) {
|
|
2086
|
-
// eslint-disable-line no-unused-vars
|
|
2087
2052
|
throw new EmberError(`Cannot set read-only property '${keyName}' on object: ${inspect(obj)}`);
|
|
2088
2053
|
}
|
|
2089
2054
|
|
|
@@ -2399,6 +2364,7 @@ if (DEBUG) {
|
|
|
2399
2364
|
Libraries.prototype.logVersions = function () {
|
|
2400
2365
|
let libs = this._registry;
|
|
2401
2366
|
let nameLengths = libs.map(item => get(item, 'name.length'));
|
|
2367
|
+
assert('nameLengths is number array', nameLengths instanceof Array && nameLengths.every(n => typeof n === 'number'));
|
|
2402
2368
|
let maxNameLength = Math.max.apply(null, nameLengths);
|
|
2403
2369
|
debug('-------------------------------');
|
|
2404
2370
|
|
|
@@ -2415,39 +2381,6 @@ if (DEBUG) {
|
|
|
2415
2381
|
const LIBRARIES = new Libraries();
|
|
2416
2382
|
LIBRARIES.registerCoreLibrary('Ember', VERSION);
|
|
2417
2383
|
|
|
2418
|
-
/**
|
|
2419
|
-
@module @ember/object
|
|
2420
|
-
*/
|
|
2421
|
-
|
|
2422
|
-
/**
|
|
2423
|
-
To get multiple properties at once, call `getProperties`
|
|
2424
|
-
with an object followed by a list of strings or an array:
|
|
2425
|
-
|
|
2426
|
-
```javascript
|
|
2427
|
-
import { getProperties } from '@ember/object';
|
|
2428
|
-
|
|
2429
|
-
getProperties(record, 'firstName', 'lastName', 'zipCode');
|
|
2430
|
-
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
|
|
2431
|
-
```
|
|
2432
|
-
|
|
2433
|
-
is equivalent to:
|
|
2434
|
-
|
|
2435
|
-
```javascript
|
|
2436
|
-
import { getProperties } from '@ember/object';
|
|
2437
|
-
|
|
2438
|
-
getProperties(record, ['firstName', 'lastName', 'zipCode']);
|
|
2439
|
-
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
|
|
2440
|
-
```
|
|
2441
|
-
|
|
2442
|
-
@method getProperties
|
|
2443
|
-
@static
|
|
2444
|
-
@for @ember/object
|
|
2445
|
-
@param {Object} obj
|
|
2446
|
-
@param {String...|Array} list of keys to get
|
|
2447
|
-
@return {Object}
|
|
2448
|
-
@public
|
|
2449
|
-
*/
|
|
2450
|
-
|
|
2451
2384
|
function getProperties(obj, keys) {
|
|
2452
2385
|
let ret = {};
|
|
2453
2386
|
let propertyNames = arguments;
|
|
@@ -3076,6 +3009,7 @@ const MIXINS = new _WeakSet();
|
|
|
3076
3009
|
*/
|
|
3077
3010
|
|
|
3078
3011
|
class Mixin {
|
|
3012
|
+
/** @internal */
|
|
3079
3013
|
constructor(mixins, properties) {
|
|
3080
3014
|
MIXINS.add(this);
|
|
3081
3015
|
this.properties = extractAccessors(properties);
|
|
@@ -3116,6 +3050,8 @@ class Mixin {
|
|
|
3116
3050
|
} // returns the mixins currently applied to the specified object
|
|
3117
3051
|
// TODO: Make `mixin`
|
|
3118
3052
|
|
|
3053
|
+
/** @internal */
|
|
3054
|
+
|
|
3119
3055
|
|
|
3120
3056
|
static mixins(obj) {
|
|
3121
3057
|
let meta$$1 = peekMeta(obj);
|
|
@@ -3137,6 +3073,7 @@ class Mixin {
|
|
|
3137
3073
|
@method reopen
|
|
3138
3074
|
@param arguments*
|
|
3139
3075
|
@private
|
|
3076
|
+
@internal
|
|
3140
3077
|
*/
|
|
3141
3078
|
|
|
3142
3079
|
|
|
@@ -3161,6 +3098,7 @@ class Mixin {
|
|
|
3161
3098
|
@param obj
|
|
3162
3099
|
@return applied object
|
|
3163
3100
|
@private
|
|
3101
|
+
@internal
|
|
3164
3102
|
*/
|
|
3165
3103
|
|
|
3166
3104
|
|
|
@@ -3172,6 +3110,8 @@ class Mixin {
|
|
|
3172
3110
|
// _hideKeys disables enumerablity when applying the mixin. This is a hack, and we should stop mutating the array prototype by default 😫
|
|
3173
3111
|
return applyMixin(obj, [this], _hideKeys);
|
|
3174
3112
|
}
|
|
3113
|
+
/** @internal */
|
|
3114
|
+
|
|
3175
3115
|
|
|
3176
3116
|
applyPartial(obj) {
|
|
3177
3117
|
return applyMixin(obj, [this]);
|
|
@@ -3181,6 +3121,7 @@ class Mixin {
|
|
|
3181
3121
|
@param obj
|
|
3182
3122
|
@return {Boolean}
|
|
3183
3123
|
@private
|
|
3124
|
+
@internal
|
|
3184
3125
|
*/
|
|
3185
3126
|
|
|
3186
3127
|
|
|
@@ -3201,16 +3142,22 @@ class Mixin {
|
|
|
3201
3142
|
|
|
3202
3143
|
return meta$$1.hasMixin(this);
|
|
3203
3144
|
}
|
|
3145
|
+
/** @internal */
|
|
3146
|
+
|
|
3204
3147
|
|
|
3205
3148
|
without(...args) {
|
|
3206
3149
|
let ret = new Mixin([this]);
|
|
3207
3150
|
ret._without = args;
|
|
3208
3151
|
return ret;
|
|
3209
3152
|
}
|
|
3153
|
+
/** @internal */
|
|
3154
|
+
|
|
3210
3155
|
|
|
3211
3156
|
keys() {
|
|
3212
3157
|
return _keys(this);
|
|
3213
3158
|
}
|
|
3159
|
+
/** @internal */
|
|
3160
|
+
|
|
3214
3161
|
|
|
3215
3162
|
toString() {
|
|
3216
3163
|
return '(unknown mixin)';
|
|
@@ -3292,11 +3239,39 @@ function _keys(mixin, ret = new Set(), seen = new Set()) {
|
|
|
3292
3239
|
|
|
3293
3240
|
return ret;
|
|
3294
3241
|
}
|
|
3242
|
+
/**
|
|
3243
|
+
Specify a method that observes property changes.
|
|
3244
|
+
|
|
3245
|
+
```javascript
|
|
3246
|
+
import EmberObject from '@ember/object';
|
|
3247
|
+
import { observer } from '@ember/object';
|
|
3248
|
+
|
|
3249
|
+
export default EmberObject.extend({
|
|
3250
|
+
valueObserver: observer('value', function() {
|
|
3251
|
+
// Executes whenever the "value" property changes
|
|
3252
|
+
})
|
|
3253
|
+
});
|
|
3254
|
+
```
|
|
3255
|
+
|
|
3256
|
+
Also available as `Function.prototype.observes` if prototype extensions are
|
|
3257
|
+
enabled.
|
|
3258
|
+
|
|
3259
|
+
@method observer
|
|
3260
|
+
@for @ember/object
|
|
3261
|
+
@param {String} propertyNames*
|
|
3262
|
+
@param {Function} func
|
|
3263
|
+
@return func
|
|
3264
|
+
@public
|
|
3265
|
+
@static
|
|
3266
|
+
*/
|
|
3267
|
+
|
|
3295
3268
|
|
|
3296
3269
|
function observer(...args) {
|
|
3297
3270
|
let funcOrDef = args.pop();
|
|
3298
3271
|
assert('observer must be provided a function or an observer definition', typeof funcOrDef === 'function' || typeof funcOrDef === 'object' && funcOrDef !== null);
|
|
3299
|
-
let func
|
|
3272
|
+
let func;
|
|
3273
|
+
let dependentKeys;
|
|
3274
|
+
let sync;
|
|
3300
3275
|
|
|
3301
3276
|
if (typeof funcOrDef === 'function') {
|
|
3302
3277
|
func = funcOrDef;
|
|
@@ -144,10 +144,15 @@ ControllerMixin.reopen({
|
|
|
144
144
|
@public
|
|
145
145
|
*/
|
|
146
146
|
transitionToRoute(...args) {
|
|
147
|
+
var _a;
|
|
148
|
+
|
|
147
149
|
deprecateTransitionMethods('controller', 'transitionToRoute'); // target may be either another controller or a router
|
|
148
150
|
|
|
149
|
-
let target = get(this, 'target');
|
|
150
|
-
|
|
151
|
+
let target = get(this, 'target'); // SAFETY: We can't actually assert that this is a full Controller or Router since some tests
|
|
152
|
+
// mock out an object that only has the single method. Since this is deprecated, I think it's
|
|
153
|
+
// ok to be a little less than proper here.
|
|
154
|
+
|
|
155
|
+
let method = (_a = target.transitionToRoute) !== null && _a !== void 0 ? _a : target.transitionTo;
|
|
151
156
|
return method.apply(target, prefixRouteNameArg(this, args));
|
|
152
157
|
},
|
|
153
158
|
|
|
@@ -201,10 +206,15 @@ ControllerMixin.reopen({
|
|
|
201
206
|
@public
|
|
202
207
|
*/
|
|
203
208
|
replaceRoute(...args) {
|
|
209
|
+
var _a;
|
|
210
|
+
|
|
204
211
|
deprecateTransitionMethods('controller', 'replaceRoute'); // target may be either another controller or a router
|
|
205
212
|
|
|
206
|
-
let target = get(this, 'target');
|
|
207
|
-
|
|
213
|
+
let target = get(this, 'target'); // SAFETY: We can't actually assert that this is a full Controller or Router since some tests
|
|
214
|
+
// mock out an object that only has the single method. Since this is deprecated, I think it's
|
|
215
|
+
// ok to be a little less than proper here.
|
|
216
|
+
|
|
217
|
+
let method = (_a = target.replaceRoute) !== null && _a !== void 0 ? _a : target.replaceWith;
|
|
208
218
|
return method.apply(target, prefixRouteNameArg(this, args));
|
|
209
219
|
}
|
|
210
220
|
|
|
@@ -82,7 +82,9 @@ export default class AutoLocation extends EmberObject {
|
|
|
82
82
|
implementation = 'none';
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
let
|
|
85
|
+
let owner = getOwner(this);
|
|
86
|
+
assert('AutoLocation is unexpectedly missing an owner', owner);
|
|
87
|
+
let concrete = owner.lookup(`location:${implementation}`);
|
|
86
88
|
assert(`Could not find location '${implementation}'.`, concrete !== undefined);
|
|
87
89
|
set(concrete, 'rootURL', rootURL);
|
|
88
90
|
set(this, 'concreteImplementation', concrete);
|
|
@@ -56,7 +56,8 @@ export default class RouterService extends Service {
|
|
|
56
56
|
return router;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
let owner = getOwner(this);
|
|
60
|
+
assert('RouterService is unexpectedly missing an owner', owner);
|
|
60
61
|
router = owner.lookup('router:main');
|
|
61
62
|
return this[ROUTER] = router;
|
|
62
63
|
}
|
|
@@ -65,46 +66,6 @@ export default class RouterService extends Service {
|
|
|
65
66
|
super.willDestroy(...arguments);
|
|
66
67
|
this[ROUTER] = null;
|
|
67
68
|
}
|
|
68
|
-
/**
|
|
69
|
-
Transition the application into another route. The route may
|
|
70
|
-
be either a single route or route path:
|
|
71
|
-
See [transitionTo](/ember/release/classes/Route/methods/transitionTo?anchor=transitionTo) for more info.
|
|
72
|
-
Calling `transitionTo` from the Router service will cause default query parameter values to be included in the URL.
|
|
73
|
-
This behavior is different from calling `transitionTo` on a route or `transitionToRoute` on a controller.
|
|
74
|
-
See the [Router Service RFC](https://github.com/emberjs/rfcs/blob/master/text/0095-router-service.md#query-parameter-semantics) for more info.
|
|
75
|
-
In the following example we use the Router service to navigate to a route with a
|
|
76
|
-
specific model from a Component in the first action, and in the second we trigger
|
|
77
|
-
a query-params only transition.
|
|
78
|
-
```app/components/example.js
|
|
79
|
-
import Component from '@glimmer/component';
|
|
80
|
-
import { action } from '@ember/object';
|
|
81
|
-
import { service } from '@ember/service';
|
|
82
|
-
export default class extends Component {
|
|
83
|
-
@service router;
|
|
84
|
-
@action
|
|
85
|
-
goToComments(post) {
|
|
86
|
-
this.router.transitionTo('comments', post);
|
|
87
|
-
}
|
|
88
|
-
@action
|
|
89
|
-
fetchMoreComments(latestComment) {
|
|
90
|
-
this.router.transitionTo({
|
|
91
|
-
queryParams: { commentsAfter: latestComment }
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
@method transitionTo
|
|
97
|
-
@param {String} [routeNameOrUrl] the name of the route or a URL
|
|
98
|
-
@param {...Object} [models] the model(s) or identifier(s) to be used while
|
|
99
|
-
transitioning to the route.
|
|
100
|
-
@param {Object} [options] optional hash with a queryParams property
|
|
101
|
-
containing a mapping of query parameters. May be supplied as the only
|
|
102
|
-
parameter to trigger a query-parameter-only transition.
|
|
103
|
-
@return {Transition} the transition object associated with this
|
|
104
|
-
attempted transition
|
|
105
|
-
@public
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
69
|
|
|
109
70
|
transitionTo(...args) {
|
|
110
71
|
if (resemblesURL(args[0])) {
|
|
@@ -157,9 +118,7 @@ export default class RouterService extends Service {
|
|
|
157
118
|
*/
|
|
158
119
|
|
|
159
120
|
|
|
160
|
-
replaceWith()
|
|
161
|
-
/* routeNameOrUrl, ...models, options */
|
|
162
|
-
{
|
|
121
|
+
replaceWith() {
|
|
163
122
|
return this.transitionTo(...arguments).method('replace');
|
|
164
123
|
}
|
|
165
124
|
/**
|
|
@@ -304,10 +263,7 @@ export default class RouterService extends Service {
|
|
|
304
263
|
// does not correctly account for `undefined` values for `routeName`.
|
|
305
264
|
// Spoilers: under the hood this currently uses router.js APIs which
|
|
306
265
|
// *do not* account for this being `undefined`.
|
|
307
|
-
routeName, models,
|
|
308
|
-
// type system here *correctly* reports as incorrect, because it may be
|
|
309
|
-
// just an empty object.
|
|
310
|
-
queryParams, true
|
|
266
|
+
routeName, models, queryParams, true
|
|
311
267
|
/* fromRouterService */
|
|
312
268
|
);
|
|
313
269
|
|
|
@@ -398,7 +354,9 @@ if (true
|
|
|
398
354
|
|
|
399
355
|
assert(`The route "${pivotRouteName}" was not found`, this._router.hasRoute(pivotRouteName));
|
|
400
356
|
assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
|
|
401
|
-
let
|
|
357
|
+
let owner = getOwner(this);
|
|
358
|
+
assert('RouterService is unexpectedly missing an owner', owner);
|
|
359
|
+
let pivotRoute = owner.lookup(`route:${pivotRouteName}`);
|
|
402
360
|
return this._router._routerMicrolib.refresh(pivotRoute);
|
|
403
361
|
}
|
|
404
362
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { getOwner } from '@ember/-internals/owner';
|
|
5
5
|
import { symbol } from '@ember/-internals/utils';
|
|
6
|
+
import { assert } from '@ember/debug';
|
|
6
7
|
import { readOnly } from '@ember/object/computed';
|
|
7
8
|
import Service from '@ember/service';
|
|
8
9
|
const ROUTER = symbol('ROUTER');
|
|
@@ -25,7 +26,8 @@ export default class RoutingService extends Service {
|
|
|
25
26
|
return router;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
let owner = getOwner(this);
|
|
30
|
+
assert('RoutingService is unexpectedly missing an owner', owner);
|
|
29
31
|
router = owner.lookup('router:main');
|
|
30
32
|
router.setupRouter();
|
|
31
33
|
return this[ROUTER] = router;
|
|
@@ -88,7 +88,9 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
88
88
|
|
|
89
89
|
_setRouteName(name) {
|
|
90
90
|
this.routeName = name;
|
|
91
|
-
|
|
91
|
+
let owner = getOwner(this);
|
|
92
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
93
|
+
this.fullRouteName = getEngineRouteName(owner, name);
|
|
92
94
|
}
|
|
93
95
|
/**
|
|
94
96
|
@private
|
|
@@ -106,9 +108,10 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
106
108
|
if (!names.length) {
|
|
107
109
|
routeInfo = dynamicParent;
|
|
108
110
|
names = routeInfo && routeInfo['_names'] || [];
|
|
109
|
-
}
|
|
111
|
+
} // SAFETY: Since `_qp` is protected we can't infer the type
|
|
112
|
+
|
|
110
113
|
|
|
111
|
-
let qps = get(this, '_qp.qps
|
|
114
|
+
let qps = get(this, '_qp').qps;
|
|
112
115
|
let namePaths = new Array(names.length);
|
|
113
116
|
|
|
114
117
|
for (let a = 0; a < names.length; ++a) {
|
|
@@ -187,7 +190,9 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
187
190
|
|
|
188
191
|
|
|
189
192
|
paramsFor(name) {
|
|
190
|
-
let
|
|
193
|
+
let owner = getOwner(this);
|
|
194
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
195
|
+
let route = owner.lookup(`route:${name}`);
|
|
191
196
|
|
|
192
197
|
if (route === undefined) {
|
|
193
198
|
return {};
|
|
@@ -301,8 +306,9 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
301
306
|
|
|
302
307
|
|
|
303
308
|
_internalReset(isExiting, transition) {
|
|
304
|
-
let controller = this.controller;
|
|
305
|
-
|
|
309
|
+
let controller = this.controller; // SAFETY: Since `_qp` is protected we can't infer the type
|
|
310
|
+
|
|
311
|
+
controller['_qpDelegate'] = get(this, '_qp').states.inactive;
|
|
306
312
|
this.resetController(controller, isExiting, transition);
|
|
307
313
|
}
|
|
308
314
|
/**
|
|
@@ -774,18 +780,18 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
774
780
|
controller = definedController;
|
|
775
781
|
} else {
|
|
776
782
|
controller = this.generateController(controllerName);
|
|
777
|
-
} //
|
|
778
|
-
// referenced in action handlers. Side effects. Side effects everywhere.
|
|
783
|
+
} // SAFETY: Since `_qp` is protected we can't infer the type
|
|
779
784
|
|
|
780
785
|
|
|
786
|
+
let queryParams = get(this, '_qp'); // Assign the route's controller so that it can more easily be
|
|
787
|
+
// referenced in action handlers. Side effects. Side effects everywhere.
|
|
788
|
+
|
|
781
789
|
if (!this.controller) {
|
|
782
|
-
let
|
|
783
|
-
let propNames = qp !== undefined ? get(qp, 'propertyNames') : [];
|
|
790
|
+
let propNames = queryParams.propertyNames;
|
|
784
791
|
addQueryParamsObservers(controller, propNames);
|
|
785
792
|
this.controller = controller;
|
|
786
793
|
}
|
|
787
794
|
|
|
788
|
-
let queryParams = get(this, '_qp');
|
|
789
795
|
let states = queryParams.states;
|
|
790
796
|
controller._qpDelegate = states.allowOverrides;
|
|
791
797
|
|
|
@@ -994,8 +1000,9 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
994
1000
|
|
|
995
1001
|
|
|
996
1002
|
model(params, transition) {
|
|
997
|
-
let name, sawParams, value;
|
|
998
|
-
|
|
1003
|
+
let name, sawParams, value; // SAFETY: Since `_qp` is protected we can't infer the type
|
|
1004
|
+
|
|
1005
|
+
let queryParams = get(this, '_qp').map;
|
|
999
1006
|
|
|
1000
1007
|
for (let prop in params) {
|
|
1001
1008
|
if (prop === 'queryParams' || queryParams && prop in queryParams) {
|
|
@@ -1105,7 +1112,6 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
1105
1112
|
|
|
1106
1113
|
|
|
1107
1114
|
setupController(controller, context, _transition) {
|
|
1108
|
-
// eslint-disable-line no-unused-vars
|
|
1109
1115
|
if (controller && context !== undefined) {
|
|
1110
1116
|
set(controller, 'model', context);
|
|
1111
1117
|
}
|
|
@@ -1134,6 +1140,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
1134
1140
|
|
|
1135
1141
|
controllerFor(name, _skipAssert) {
|
|
1136
1142
|
let owner = getOwner(this);
|
|
1143
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
1137
1144
|
let route = owner.lookup(`route:${name}`);
|
|
1138
1145
|
|
|
1139
1146
|
if (route && route.controllerName) {
|
|
@@ -1167,6 +1174,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
1167
1174
|
|
|
1168
1175
|
generateController(name) {
|
|
1169
1176
|
let owner = getOwner(this);
|
|
1177
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
1170
1178
|
return generateController(owner, name);
|
|
1171
1179
|
}
|
|
1172
1180
|
/**
|
|
@@ -1208,6 +1216,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
1208
1216
|
modelFor(_name) {
|
|
1209
1217
|
let name;
|
|
1210
1218
|
let owner = getOwner(this);
|
|
1219
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
1211
1220
|
let transition = this._router && this._router._routerMicrolib ? this._router._routerMicrolib.activeTransition : undefined; // Only change the route name when there is an active transition.
|
|
1212
1221
|
// Otherwise, use the passed in route name.
|
|
1213
1222
|
|
|
@@ -1329,7 +1338,8 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
1329
1338
|
|
|
1330
1339
|
|
|
1331
1340
|
get store() {
|
|
1332
|
-
|
|
1341
|
+
const owner = getOwner(this);
|
|
1342
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
1333
1343
|
let routeName = this.routeName;
|
|
1334
1344
|
return {
|
|
1335
1345
|
find(name, value) {
|
|
@@ -1361,6 +1371,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
1361
1371
|
let combinedQueryParameterConfiguration;
|
|
1362
1372
|
let controllerName = this.controllerName || this.routeName;
|
|
1363
1373
|
let owner = getOwner(this);
|
|
1374
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
1364
1375
|
let controller = owner.lookup(`controller:${controllerName}`);
|
|
1365
1376
|
let queryParameterConfiguraton = get(this, 'queryParams');
|
|
1366
1377
|
let hasRouterDefinedQueryParams = Object.keys(queryParameterConfiguraton).length > 0;
|
|
@@ -1398,7 +1409,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
1398
1409
|
|
|
1399
1410
|
let desc = combinedQueryParameterConfiguration[propName];
|
|
1400
1411
|
let scope = desc.scope || 'model';
|
|
1401
|
-
let parts;
|
|
1412
|
+
let parts = undefined;
|
|
1402
1413
|
|
|
1403
1414
|
if (scope === 'controller') {
|
|
1404
1415
|
parts = [];
|
|
@@ -1522,6 +1533,7 @@ function buildRenderOptions(route, nameOrOptions, options) {
|
|
|
1522
1533
|
|
|
1523
1534
|
assert('You passed undefined as the outlet name.', isDefaultRender || !(options && 'outlet' in options && options.outlet === undefined));
|
|
1524
1535
|
let owner = getOwner(route);
|
|
1536
|
+
assert('Route is unexpectedly missing an owner', owner);
|
|
1525
1537
|
let name, templateName, into, outlet, model;
|
|
1526
1538
|
let controller = undefined;
|
|
1527
1539
|
|
|
@@ -1594,13 +1606,12 @@ function buildRenderOptions(route, nameOrOptions, options) {
|
|
|
1594
1606
|
}
|
|
1595
1607
|
|
|
1596
1608
|
export function getFullQueryParams(router, state) {
|
|
1597
|
-
if (state
|
|
1598
|
-
return state
|
|
1609
|
+
if (state.fullQueryParams) {
|
|
1610
|
+
return state.fullQueryParams;
|
|
1599
1611
|
}
|
|
1600
1612
|
|
|
1601
|
-
let fullQueryParamsState = {};
|
|
1602
1613
|
let haveAllRouteInfosResolved = state.routeInfos.every(routeInfo => routeInfo.route);
|
|
1603
|
-
Object.assign(
|
|
1614
|
+
let fullQueryParamsState = Object.assign({}, state.queryParams);
|
|
1604
1615
|
|
|
1605
1616
|
router._deserializeQueryParams(state.routeInfos, fullQueryParamsState); // only cache query params state if all routeinfos have resolved; it's possible
|
|
1606
1617
|
// for lazy routes to not have resolved when `getFullQueryParams` is called, so
|
|
@@ -1608,24 +1619,25 @@ export function getFullQueryParams(router, state) {
|
|
|
1608
1619
|
|
|
1609
1620
|
|
|
1610
1621
|
if (haveAllRouteInfosResolved) {
|
|
1611
|
-
state
|
|
1622
|
+
state.fullQueryParams = fullQueryParamsState;
|
|
1612
1623
|
}
|
|
1613
1624
|
|
|
1614
1625
|
return fullQueryParamsState;
|
|
1615
1626
|
}
|
|
1616
1627
|
|
|
1617
1628
|
function getQueryParamsFor(route, state) {
|
|
1618
|
-
state
|
|
1629
|
+
state.queryParamsFor = state.queryParamsFor || {};
|
|
1619
1630
|
let name = route.fullRouteName;
|
|
1620
1631
|
|
|
1621
|
-
if (state
|
|
1622
|
-
return state
|
|
1632
|
+
if (state.queryParamsFor[name]) {
|
|
1633
|
+
return state.queryParamsFor[name];
|
|
1623
1634
|
}
|
|
1624
1635
|
|
|
1625
1636
|
let fullQueryParams = getFullQueryParams(route._router, state);
|
|
1626
|
-
let params = state
|
|
1637
|
+
let params = state.queryParamsFor[name] = {}; // Copy over all the query params for this route/controller into params hash.
|
|
1638
|
+
// SAFETY: Since `_qp` is protected we can't infer the type
|
|
1627
1639
|
|
|
1628
|
-
let qps = get(route, '_qp.qps
|
|
1640
|
+
let qps = get(route, '_qp').qps;
|
|
1629
1641
|
|
|
1630
1642
|
for (let i = 0; i < qps.length; ++i) {
|
|
1631
1643
|
// Put deserialized qp on params hash.
|
|
@@ -1635,10 +1647,12 @@ function getQueryParamsFor(route, state) {
|
|
|
1635
1647
|
}
|
|
1636
1648
|
|
|
1637
1649
|
return params;
|
|
1638
|
-
}
|
|
1650
|
+
} // FIXME: This should probably actually return a `NativeArray` if the passed in value is an Array.
|
|
1651
|
+
|
|
1639
1652
|
|
|
1640
1653
|
function copyDefaultValue(value) {
|
|
1641
1654
|
if (Array.isArray(value)) {
|
|
1655
|
+
// SAFETY: We lost the type data about the array if we don't cast.
|
|
1642
1656
|
return emberA(value.slice());
|
|
1643
1657
|
}
|
|
1644
1658
|
|
|
@@ -1824,15 +1838,22 @@ Route.reopen({
|
|
|
1824
1838
|
@private
|
|
1825
1839
|
*/
|
|
1826
1840
|
queryParamsDidChange(changed, _totalPresent, removed) {
|
|
1841
|
+
// SAFETY: Since `_qp` is protected we can't infer the type
|
|
1827
1842
|
let qpMap = get(this, '_qp').map;
|
|
1828
1843
|
let totalChanged = Object.keys(changed).concat(Object.keys(removed));
|
|
1829
1844
|
|
|
1830
1845
|
for (let i = 0; i < totalChanged.length; ++i) {
|
|
1831
1846
|
let qp = qpMap[totalChanged[i]];
|
|
1832
1847
|
|
|
1833
|
-
if (qp
|
|
1834
|
-
this.
|
|
1835
|
-
|
|
1848
|
+
if (qp) {
|
|
1849
|
+
let options = this._optionsForQueryParam(qp);
|
|
1850
|
+
|
|
1851
|
+
assert('options exists', options && typeof options === 'object');
|
|
1852
|
+
|
|
1853
|
+
if (get(options, 'refreshModel') && this._router.currentState) {
|
|
1854
|
+
this.refresh();
|
|
1855
|
+
break;
|
|
1856
|
+
}
|
|
1836
1857
|
}
|
|
1837
1858
|
}
|
|
1838
1859
|
|
|
@@ -1867,7 +1888,8 @@ Route.reopen({
|
|
|
1867
1888
|
// param URL key corresponds to a QP property on
|
|
1868
1889
|
// this controller.
|
|
1869
1890
|
|
|
1870
|
-
let value
|
|
1891
|
+
let value;
|
|
1892
|
+
let svalue;
|
|
1871
1893
|
|
|
1872
1894
|
if (changes.has(qp.urlKey)) {
|
|
1873
1895
|
// Value updated in/before setupController
|
|
@@ -1885,9 +1907,10 @@ Route.reopen({
|
|
|
1885
1907
|
svalue = qp.serializedDefaultValue;
|
|
1886
1908
|
value = copyDefaultValue(qp.defaultValue);
|
|
1887
1909
|
}
|
|
1888
|
-
}
|
|
1910
|
+
} // SAFETY: Since `_qp` is protected we can't infer the type
|
|
1911
|
+
|
|
1889
1912
|
|
|
1890
|
-
controller._qpDelegate = get(route, '_qp.states.inactive
|
|
1913
|
+
controller._qpDelegate = get(route, '_qp').states.inactive;
|
|
1891
1914
|
let thisQueryParamChanged = svalue !== qp.serializedValue;
|
|
1892
1915
|
|
|
1893
1916
|
if (thisQueryParamChanged) {
|
|
@@ -1932,6 +1955,7 @@ Route.reopen({
|
|
|
1932
1955
|
}
|
|
1933
1956
|
|
|
1934
1957
|
qpMeta.qps.forEach(qp => {
|
|
1958
|
+
// SAFETY: Since `_qp` is protected we can't infer the type
|
|
1935
1959
|
let routeQpMeta = get(qp.route, '_qp');
|
|
1936
1960
|
let finalizedController = qp.route.controller;
|
|
1937
1961
|
finalizedController['_qpDelegate'] = get(routeQpMeta, 'states.active');
|