ember-source 4.3.0-alpha.1 → 4.3.0-beta.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.
- package/CHANGELOG.md +6 -2
- 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/dependencies/router_js.js +66 -31
- package/dist/ember-template-compiler.js +1250 -861
- 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 +3712 -3159
- 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 +16 -11
- 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 +161 -125
- package/dist/packages/@ember/-internals/meta/lib/meta.js +67 -11
- package/dist/packages/@ember/-internals/metal/index.js +95 -121
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +24 -12
- 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 +117 -197
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +2 -2
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +147 -402
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +82 -40
- package/dist/packages/@ember/-internals/routing/lib/utils.js +48 -25
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- 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 +11 -9
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +2 -4
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +2 -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/controller/index.js +3 -54
- package/dist/packages/@ember/debug/index.js +1 -1
- package/dist/packages/@ember/debug/lib/deprecate.js +12 -10
- package/dist/packages/@ember/instrumentation/index.js +9 -13
- package/dist/packages/@ember/object/compat.js +16 -7
- package/dist/packages/@ember/polyfills/lib/assign.js +1 -0
- package/dist/packages/@ember/routing/router-service.js +1 -0
- package/dist/packages/@ember/runloop/index.js +9 -9
- package/dist/packages/@ember/service/index.js +6 -73
- 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 +2588 -1839
- package/package.json +27 -27
- 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
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length,
|
|
3
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
4
|
+
d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
import { getOwner } from '@ember/-internals/owner';
|
|
2
10
|
import { Evented } from '@ember/-internals/runtime';
|
|
3
11
|
import { symbol } from '@ember/-internals/utils';
|
|
@@ -15,40 +23,106 @@ function cleanURL(url, rootURL) {
|
|
|
15
23
|
|
|
16
24
|
return url.substr(rootURL.length, url.length);
|
|
17
25
|
}
|
|
18
|
-
/**
|
|
19
|
-
The Router service is the public API that provides access to the router.
|
|
20
|
-
|
|
21
|
-
The immediate benefit of the Router service is that you can inject it into components,
|
|
22
|
-
giving them a friendly way to initiate transitions and ask questions about the current
|
|
23
|
-
global router state.
|
|
24
|
-
|
|
25
|
-
In this example, the Router service is injected into a component to initiate a transition
|
|
26
|
-
to a dedicated route:
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
class RouterService extends Service.extend(Evented) {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
/**
|
|
31
|
+
The `routeWillChange` event is fired at the beginning of any
|
|
32
|
+
attempted transition with a `Transition` object as the sole
|
|
33
|
+
argument. This action can be used for aborting, redirecting,
|
|
34
|
+
or decorating the transition from the currently active routes.
|
|
35
|
+
A good example is preventing navigation when a form is
|
|
36
|
+
half-filled out:
|
|
37
|
+
```app/routes/contact-form.js
|
|
38
|
+
import Route from '@ember/routing';
|
|
39
|
+
import { service } from '@ember/service';
|
|
40
|
+
export default class extends Route {
|
|
41
|
+
@service router;
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
this.router.on('routeWillChange', (transition) => {
|
|
45
|
+
if (!transition.to.find(route => route.name === this.routeName)) {
|
|
46
|
+
alert("Please save or cancel your changes.");
|
|
47
|
+
transition.abort();
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
The `routeWillChange` event fires whenever a new route is chosen as the desired target of a transition. This includes `transitionTo`, `replaceWith`, all redirection for any reason including error handling, and abort. Aborting implies changing the desired target back to where you already were. Once a transition has completed, `routeDidChange` fires.
|
|
54
|
+
@event routeWillChange
|
|
55
|
+
@param {Transition} transition
|
|
56
|
+
@public
|
|
57
|
+
*/
|
|
35
58
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
59
|
+
/**
|
|
60
|
+
The `routeDidChange` event only fires once a transition has settled.
|
|
61
|
+
This includes aborts and error substates. Like the `routeWillChange` event
|
|
62
|
+
it receives a Transition as the sole argument.
|
|
63
|
+
A good example is sending some analytics when the route has transitioned:
|
|
64
|
+
```app/routes/contact-form.js
|
|
65
|
+
import Route from '@ember/routing';
|
|
66
|
+
import { service } from '@ember/service';
|
|
67
|
+
export default class extends Route {
|
|
68
|
+
@service router;
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
this.router.on('routeDidChange', (transition) => {
|
|
72
|
+
ga.send('pageView', {
|
|
73
|
+
current: transition.to.name,
|
|
74
|
+
from: transition.from.name
|
|
75
|
+
});
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
`routeDidChange` will be called after any `Route`'s
|
|
81
|
+
[didTransition](/ember/release/classes/Route/events/didTransition?anchor=didTransition)
|
|
82
|
+
action has been fired.
|
|
83
|
+
The updates of properties
|
|
84
|
+
[currentURL](/ember/release/classes/RouterService/properties/currentURL?anchor=currentURL),
|
|
85
|
+
[currentRouteName](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRouteName)
|
|
86
|
+
and
|
|
87
|
+
[currentRoute](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRoute)
|
|
88
|
+
are completed at the time `routeDidChange` is called.
|
|
89
|
+
@event routeDidChange
|
|
90
|
+
@param {Transition} transition
|
|
91
|
+
@public
|
|
92
|
+
*/
|
|
93
|
+
// Canary features
|
|
42
94
|
|
|
43
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Refreshes all currently active routes, doing a full transition.
|
|
97
|
+
* If a route name is provided and refers to a currently active route,
|
|
98
|
+
* it will refresh only that route and its descendents.
|
|
99
|
+
* Returns a promise that will be resolved once the refresh is complete.
|
|
100
|
+
* All resetController, beforeModel, model, afterModel, redirect, and setupController
|
|
101
|
+
* hooks will be called again. You will get new data from the model hook.
|
|
102
|
+
*
|
|
103
|
+
* @method refresh
|
|
104
|
+
* @param {String} [routeName] the route to refresh (along with all child routes)
|
|
105
|
+
* @return Transition
|
|
106
|
+
* @category EMBER_ROUTING_ROUTER_SERVICE_REFRESH
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
44
109
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
110
|
+
this.refresh = true
|
|
111
|
+
/* EMBER_ROUTING_ROUTER_SERVICE_REFRESH */
|
|
112
|
+
? function (pivotRouteName) {
|
|
113
|
+
if (!pivotRouteName) {
|
|
114
|
+
return this._router._routerMicrolib.refresh();
|
|
115
|
+
}
|
|
49
116
|
|
|
117
|
+
assert(`The route "${pivotRouteName}" was not found`, this._router.hasRoute(pivotRouteName));
|
|
118
|
+
assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
|
|
119
|
+
let owner = getOwner(this);
|
|
120
|
+
assert('RouterService is unexpectedly missing an owner', owner);
|
|
121
|
+
let pivotRoute = owner.lookup(`route:${pivotRouteName}`);
|
|
122
|
+
return this._router._routerMicrolib.refresh(pivotRoute);
|
|
123
|
+
} : undefined;
|
|
124
|
+
}
|
|
50
125
|
|
|
51
|
-
export default class RouterService extends Service {
|
|
52
126
|
get _router() {
|
|
53
127
|
let router = this[ROUTER];
|
|
54
128
|
|
|
@@ -56,19 +130,19 @@ export default class RouterService extends Service {
|
|
|
56
130
|
return router;
|
|
57
131
|
}
|
|
58
132
|
|
|
59
|
-
|
|
133
|
+
let owner = getOwner(this);
|
|
134
|
+
assert('RouterService is unexpectedly missing an owner', owner);
|
|
60
135
|
router = owner.lookup('router:main');
|
|
61
136
|
return this[ROUTER] = router;
|
|
62
137
|
}
|
|
63
138
|
|
|
64
139
|
willDestroy() {
|
|
65
|
-
super.willDestroy(
|
|
140
|
+
super.willDestroy();
|
|
66
141
|
this[ROUTER] = null;
|
|
67
142
|
}
|
|
68
143
|
/**
|
|
69
144
|
Transition the application into another route. The route may
|
|
70
145
|
be either a single route or route path:
|
|
71
|
-
See [transitionTo](/ember/release/classes/Route/methods/transitionTo?anchor=transitionTo) for more info.
|
|
72
146
|
Calling `transitionTo` from the Router service will cause default query parameter values to be included in the URL.
|
|
73
147
|
This behavior is different from calling `transitionTo` on a route or `transitionToRoute` on a controller.
|
|
74
148
|
See the [Router Service RFC](https://github.com/emberjs/rfcs/blob/master/text/0095-router-service.md#query-parameter-semantics) for more info.
|
|
@@ -130,7 +204,6 @@ export default class RouterService extends Service {
|
|
|
130
204
|
When the user clicks the "back" button in the browser, there will be fewer steps.
|
|
131
205
|
This is most commonly used to manage redirects in a way that does not cause confusing additions
|
|
132
206
|
to the user's browsing history.
|
|
133
|
-
See [replaceWith](/ember/release/classes/Route/methods/replaceWith?anchor=replaceWith) for more info.
|
|
134
207
|
Calling `replaceWith` from the Router service will cause default query parameter values to be included in the URL.
|
|
135
208
|
This behavior is different from calling `replaceWith` on a route.
|
|
136
209
|
See the [Router Service RFC](https://github.com/emberjs/rfcs/blob/master/text/0095-router-service.md#query-parameter-semantics) for more info.
|
|
@@ -157,10 +230,8 @@ export default class RouterService extends Service {
|
|
|
157
230
|
*/
|
|
158
231
|
|
|
159
232
|
|
|
160
|
-
replaceWith()
|
|
161
|
-
|
|
162
|
-
{
|
|
163
|
-
return this.transitionTo(...arguments).method('replace');
|
|
233
|
+
replaceWith(...args) {
|
|
234
|
+
return this.transitionTo(...args).method('replace');
|
|
164
235
|
}
|
|
165
236
|
/**
|
|
166
237
|
Generate a URL based on the supplied route name and optionally a model. The
|
|
@@ -213,8 +284,7 @@ export default class RouterService extends Service {
|
|
|
213
284
|
```
|
|
214
285
|
@method urlFor
|
|
215
286
|
@param {String} routeName the name of the route
|
|
216
|
-
@param {...Object} models the model(s)
|
|
217
|
-
transitioning to the route.
|
|
287
|
+
@param {...Object} models the model(s) for the route.
|
|
218
288
|
@param {Object} [options] optional hash with a queryParams property
|
|
219
289
|
containing a mapping of query parameters
|
|
220
290
|
@return {String} the string representing the generated URL
|
|
@@ -304,10 +374,7 @@ export default class RouterService extends Service {
|
|
|
304
374
|
// does not correctly account for `undefined` values for `routeName`.
|
|
305
375
|
// Spoilers: under the hood this currently uses router.js APIs which
|
|
306
376
|
// *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
|
|
377
|
+
routeName, models, queryParams, true
|
|
311
378
|
/* fromRouterService */
|
|
312
379
|
);
|
|
313
380
|
|
|
@@ -338,6 +405,7 @@ export default class RouterService extends Service {
|
|
|
338
405
|
```
|
|
339
406
|
@method recognize
|
|
340
407
|
@param {String} url
|
|
408
|
+
@return {RouteInfo | null}
|
|
341
409
|
@public
|
|
342
410
|
*/
|
|
343
411
|
|
|
@@ -358,6 +426,7 @@ export default class RouterService extends Service {
|
|
|
358
426
|
the browser including the app's `rootURL`.
|
|
359
427
|
@method recognizeAndLoad
|
|
360
428
|
@param {String} url
|
|
429
|
+
@return {RouteInfo}
|
|
361
430
|
@public
|
|
362
431
|
*/
|
|
363
432
|
|
|
@@ -373,163 +442,14 @@ export default class RouterService extends Service {
|
|
|
373
442
|
|
|
374
443
|
}
|
|
375
444
|
|
|
376
|
-
|
|
377
|
-
/* EMBER_ROUTING_ROUTER_SERVICE_REFRESH */
|
|
378
|
-
) {
|
|
379
|
-
RouterService.reopen({
|
|
380
|
-
/**
|
|
381
|
-
* Refreshes all currently active routes, doing a full transition.
|
|
382
|
-
* If a route name is provided and refers to a currently active route,
|
|
383
|
-
* it will refresh only that route and its descendents.
|
|
384
|
-
* Returns a promise that will be resolved once the refresh is complete.
|
|
385
|
-
* All resetController, beforeModel, model, afterModel, redirect, and setupController
|
|
386
|
-
* hooks will be called again. You will get new data from the model hook.
|
|
387
|
-
*
|
|
388
|
-
* @method refresh
|
|
389
|
-
* @param {String} [routeName] the route to refresh (along with all child routes)
|
|
390
|
-
* @return Transition
|
|
391
|
-
* @category EMBER_ROUTING_ROUTER_SERVICE_REFRESH
|
|
392
|
-
* @public
|
|
393
|
-
*/
|
|
394
|
-
refresh(pivotRouteName) {
|
|
395
|
-
if (!pivotRouteName) {
|
|
396
|
-
return this._router._routerMicrolib.refresh();
|
|
397
|
-
}
|
|
445
|
+
__decorate([readOnly('_router.currentRouteName')], RouterService.prototype, "currentRouteName", void 0);
|
|
398
446
|
|
|
399
|
-
|
|
400
|
-
assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
|
|
401
|
-
let pivotRoute = getOwner(this).lookup(`route:${pivotRouteName}`);
|
|
402
|
-
return this._router._routerMicrolib.refresh(pivotRoute);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
RouterService.reopen(Evented, {
|
|
409
|
-
/**
|
|
410
|
-
Name of the current route.
|
|
411
|
-
This property represents the logical name of the route,
|
|
412
|
-
which is comma separated.
|
|
413
|
-
For the following router:
|
|
414
|
-
```app/router.js
|
|
415
|
-
Router.map(function() {
|
|
416
|
-
this.route('about');
|
|
417
|
-
this.route('blog', function () {
|
|
418
|
-
this.route('post', { path: ':post_id' });
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
```
|
|
422
|
-
It will return:
|
|
423
|
-
* `index` when you visit `/`
|
|
424
|
-
* `about` when you visit `/about`
|
|
425
|
-
* `blog.index` when you visit `/blog`
|
|
426
|
-
* `blog.post` when you visit `/blog/some-post-id`
|
|
427
|
-
@property currentRouteName
|
|
428
|
-
@type String
|
|
429
|
-
@public
|
|
430
|
-
*/
|
|
431
|
-
currentRouteName: readOnly('_router.currentRouteName'),
|
|
447
|
+
__decorate([readOnly('_router.currentURL')], RouterService.prototype, "currentURL", void 0);
|
|
432
448
|
|
|
433
|
-
|
|
434
|
-
Current URL for the application.
|
|
435
|
-
This property represents the URL path for this route.
|
|
436
|
-
For the following router:
|
|
437
|
-
```app/router.js
|
|
438
|
-
Router.map(function() {
|
|
439
|
-
this.route('about');
|
|
440
|
-
this.route('blog', function () {
|
|
441
|
-
this.route('post', { path: ':post_id' });
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
```
|
|
445
|
-
It will return:
|
|
446
|
-
* `/` when you visit `/`
|
|
447
|
-
* `/about` when you visit `/about`
|
|
448
|
-
* `/blog` when you visit `/blog`
|
|
449
|
-
* `/blog/some-post-id` when you visit `/blog/some-post-id`
|
|
450
|
-
@property currentURL
|
|
451
|
-
@type String
|
|
452
|
-
@public
|
|
453
|
-
*/
|
|
454
|
-
currentURL: readOnly('_router.currentURL'),
|
|
449
|
+
__decorate([readOnly('_router.location')], RouterService.prototype, "location", void 0);
|
|
455
450
|
|
|
456
|
-
|
|
457
|
-
The `location` property returns what implementation of the `location` API
|
|
458
|
-
your application is using, which determines what type of URL is being used.
|
|
459
|
-
See [Location](/ember/release/classes/Location) for more information.
|
|
460
|
-
To force a particular `location` API implementation to be used in your
|
|
461
|
-
application you can set a location type on your `config/environment`.
|
|
462
|
-
For example, to set the `history` type:
|
|
463
|
-
```config/environment.js
|
|
464
|
-
'use strict';
|
|
465
|
-
module.exports = function(environment) {
|
|
466
|
-
let ENV = {
|
|
467
|
-
modulePrefix: 'router-service',
|
|
468
|
-
environment,
|
|
469
|
-
rootURL: '/',
|
|
470
|
-
locationType: 'history',
|
|
471
|
-
...
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
```
|
|
475
|
-
The following location types are available by default:
|
|
476
|
-
`auto`, `hash`, `history`, `none`.
|
|
477
|
-
See [HashLocation](/ember/release/classes/HashLocation).
|
|
478
|
-
See [HistoryLocation](/ember/release/classes/HistoryLocation).
|
|
479
|
-
See [NoneLocation](/ember/release/classes/NoneLocation).
|
|
480
|
-
See [AutoLocation](/ember/release/classes/AutoLocation).
|
|
481
|
-
@property location
|
|
482
|
-
@default 'hash'
|
|
483
|
-
@see {Location}
|
|
484
|
-
@public
|
|
485
|
-
*/
|
|
486
|
-
location: readOnly('_router.location'),
|
|
451
|
+
__decorate([readOnly('_router.rootURL')], RouterService.prototype, "rootURL", void 0);
|
|
487
452
|
|
|
488
|
-
|
|
489
|
-
The `rootURL` property represents the URL of the root of
|
|
490
|
-
the application, '/' by default.
|
|
491
|
-
This prefix is assumed on all routes defined on this app.
|
|
492
|
-
If you change the `rootURL` in your environment configuration
|
|
493
|
-
like so:
|
|
494
|
-
```config/environment.js
|
|
495
|
-
'use strict';
|
|
496
|
-
module.exports = function(environment) {
|
|
497
|
-
let ENV = {
|
|
498
|
-
modulePrefix: 'router-service',
|
|
499
|
-
environment,
|
|
500
|
-
rootURL: '/my-root',
|
|
501
|
-
…
|
|
502
|
-
}
|
|
503
|
-
]
|
|
504
|
-
```
|
|
505
|
-
This property will return `/my-root`.
|
|
506
|
-
@property rootURL
|
|
507
|
-
@default '/'
|
|
508
|
-
@public
|
|
509
|
-
*/
|
|
510
|
-
rootURL: readOnly('_router.rootURL'),
|
|
453
|
+
__decorate([readOnly('_router.currentRoute')], RouterService.prototype, "currentRoute", void 0);
|
|
511
454
|
|
|
512
|
-
|
|
513
|
-
The `currentRoute` property contains metadata about the current leaf route.
|
|
514
|
-
It returns a `RouteInfo` object that has information like the route name,
|
|
515
|
-
params, query params and more.
|
|
516
|
-
See [RouteInfo](/ember/release/classes/RouteInfo) for more info.
|
|
517
|
-
This property is guaranteed to change whenever a route transition
|
|
518
|
-
happens (even when that transition only changes parameters
|
|
519
|
-
and doesn't change the active route).
|
|
520
|
-
Usage example:
|
|
521
|
-
```app/components/header.js
|
|
522
|
-
import Component from '@glimmer/component';
|
|
523
|
-
import { service } from '@ember/service';
|
|
524
|
-
import { notEmpty } from '@ember/object/computed';
|
|
525
|
-
export default class extends Component {
|
|
526
|
-
@service router;
|
|
527
|
-
@notEmpty('router.currentRoute.child') isChildRoute;
|
|
528
|
-
});
|
|
529
|
-
```
|
|
530
|
-
@property currentRoute
|
|
531
|
-
@type RouteInfo
|
|
532
|
-
@public
|
|
533
|
-
*/
|
|
534
|
-
currentRoute: readOnly('_router.currentRoute')
|
|
535
|
-
});
|
|
455
|
+
export { RouterService as default };
|
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
/**
|
|
3
3
|
A `RouteInfoWithAttributes` is an object that contains
|
|
4
4
|
metadata, including the resolved value from the routes
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
/**
|
|
56
56
|
This is the resolved return value from the
|
|
57
57
|
route's model hook.
|
|
58
|
-
@property {Object|Array|String} attributes
|
|
58
|
+
@property {Object|Array|String|undefined} attributes
|
|
59
59
|
@public
|
|
60
60
|
*/
|
|
61
61
|
|