ember-source 3.28.5 → 4.0.0-beta.10
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 +113 -10
- 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/blueprints/initializer/files/__root__/initializers/__name__.js +0 -1
- package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js +0 -1
- 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 +3692 -5667
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +12 -560
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +4357 -12470
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/bootstrap/index.js +2 -55
- package/dist/packages/@ember/-internals/container/index.js +35 -206
- package/dist/packages/@ember/-internals/environment/index.js +3 -46
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +7 -0
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +1 -2
- package/dist/packages/@ember/-internals/glimmer/index.js +4774 -7035
- package/dist/packages/@ember/-internals/meta/lib/meta.js +2 -50
- package/dist/packages/@ember/-internals/metal/index.js +785 -1109
- package/dist/packages/@ember/-internals/overrides/index.js +1 -3
- package/dist/packages/@ember/-internals/owner/index.js +1 -19
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +1 -51
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +1 -0
- package/dist/packages/@ember/-internals/routing/lib/location/history_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +0 -7
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +34 -2
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +2 -3
- package/dist/packages/@ember/-internals/routing/lib/system/dsl.js +5 -6
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +192 -652
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +119 -248
- package/dist/packages/@ember/-internals/routing/lib/system/router_state.js +1 -2
- package/dist/packages/@ember/-internals/routing/lib/utils.js +1 -2
- package/dist/packages/@ember/-internals/runtime/index.js +1 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +4 -175
- package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +1 -18
- 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/runtime/lib/system/core_object.js +10 -141
- package/dist/packages/@ember/-internals/utils/index.js +3 -59
- package/dist/packages/@ember/-internals/views/index.js +0 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +1 -121
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -40
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +115 -190
- package/dist/packages/@ember/-internals/views/lib/views/states/destroying.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/has_element.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/in_dom.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/pre_render.js +1 -2
- package/dist/packages/@ember/application/instance.js +3 -25
- package/dist/packages/@ember/application/lib/application.js +14 -32
- package/dist/packages/@ember/canary-features/index.js +5 -6
- package/dist/packages/@ember/component/index.js +1 -1
- package/dist/packages/@ember/component/template-only.js +2 -0
- package/dist/packages/@ember/debug/lib/deprecate.js +7 -41
- package/dist/packages/@ember/deprecated-features/index.js +1 -14
- package/dist/packages/@ember/engine/index.js +3 -17
- package/dist/packages/@ember/engine/instance.js +0 -4
- package/dist/packages/@ember/helper/index.js +12 -4
- package/dist/packages/@ember/object/index.js +3 -101
- package/dist/packages/@ember/object/internals.js +0 -1
- package/dist/packages/@ember/object/lib/computed/computed_macros.js +12 -384
- package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +9 -360
- package/dist/packages/@ember/polyfills/index.js +1 -6
- package/dist/packages/@ember/polyfills/lib/assign.js +12 -28
- package/dist/packages/@ember/routing/index.js +1 -1
- package/dist/packages/@ember/runloop/index.js +1 -83
- package/dist/packages/@ember/string/index.js +1 -206
- package/dist/packages/@ember/utils/index.js +0 -1
- package/dist/packages/ember/index.js +17 -180
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/index.js +0 -2
- package/dist/packages/ember-testing/lib/helpers.js +0 -12
- package/dist/packages/ember-testing/lib/setup_for_testing.js +0 -10
- package/docs/data.json +1637 -3659
- package/lib/index.js +14 -59
- package/lib/overrides.js +0 -61
- package/lib/transforms/inject-babel-helpers.js +1 -3
- package/package.json +27 -23
- package/dist/packages/@ember/-internals/console/index.js +0 -190
- package/dist/packages/@ember/-internals/runtime/lib/copy.js +0 -119
- package/dist/packages/@ember/-internals/runtime/lib/ext/function.js +0 -155
- package/dist/packages/@ember/-internals/runtime/lib/mixins/copyable.js +0 -31
- package/dist/packages/@ember/-internals/views/lib/mixins/text_support.js +0 -357
- package/dist/packages/@ember/-internals/views/lib/system/jquery.js +0 -26
- package/dist/packages/@ember/-internals/views/lib/system/jquery_event_deprecation.js +0 -60
- package/dist/packages/@ember/application/deprecations.js +0 -25
- package/dist/packages/@ember/application/globals-resolver.js +0 -434
- package/dist/packages/@ember/application/resolver.js +0 -1
- 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/polyfills/lib/merge.js +0 -50
- package/dist/packages/@ember/routing/link-component.js +0 -17
- package/dist/packages/ember-testing/lib/events.js +0 -102
- package/dist/packages/ember-testing/lib/helpers/-is-form-control.js +0 -19
- package/dist/packages/ember-testing/lib/helpers/click.js +0 -32
- package/dist/packages/ember-testing/lib/helpers/fill_in.js +0 -47
- package/dist/packages/ember-testing/lib/helpers/find.js +0 -40
- package/dist/packages/ember-testing/lib/helpers/find_with_assert.js +0 -37
- package/dist/packages/ember-testing/lib/helpers/key_event.js +0 -37
- package/dist/packages/ember-testing/lib/helpers/trigger_event.js +0 -61
- package/dist/packages/ember-testing/lib/support.js +0 -57
- package/dist/packages/jquery/index.js +0 -2
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { privatize as P } from '@ember/-internals/container';
|
|
2
|
-
import { computed, get,
|
|
2
|
+
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
|
-
import { assert,
|
|
6
|
-
import { APP_CTRL_ROUTER_PROPS, ROUTER_EVENTS } from '@ember/deprecated-features';
|
|
5
|
+
import { assert, info } from '@ember/debug';
|
|
7
6
|
import EmberError from '@ember/error';
|
|
8
|
-
import { assign } from '@ember/polyfills';
|
|
9
7
|
import { cancel, once, run, scheduleOnce } from '@ember/runloop';
|
|
10
8
|
import { DEBUG } from '@glimmer/env';
|
|
11
9
|
import EmberLocation from '../location/api';
|
|
12
10
|
import { calculateCacheKey, extractRouteArgs, getActiveTargetName, resemblesURL } from '../utils';
|
|
13
11
|
import DSL from './dsl';
|
|
14
|
-
import { defaultSerialize, getFullQueryParams, hasDefaultSerialize, ROUTE_CONNECTIONS
|
|
12
|
+
import { defaultSerialize, getFullQueryParams, hasDefaultSerialize, ROUTE_CONNECTIONS } from './route';
|
|
15
13
|
import RouterState from './router_state';
|
|
16
14
|
import Router, { logAbort, STATE_SYMBOL } from 'router_js';
|
|
17
15
|
|
|
@@ -21,12 +19,10 @@ function defaultDidTransition(infos) {
|
|
|
21
19
|
this._cancelSlowTransitionTimer();
|
|
22
20
|
|
|
23
21
|
this.notifyPropertyChange('url');
|
|
24
|
-
this.set('currentState', this.targetState);
|
|
25
|
-
// less surprising than didTransition being out of sync.
|
|
26
|
-
|
|
27
|
-
once(this, this.trigger, 'didTransition');
|
|
22
|
+
this.set('currentState', this.targetState);
|
|
28
23
|
|
|
29
24
|
if (DEBUG) {
|
|
25
|
+
// @ts-expect-error namespace isn't public
|
|
30
26
|
if (this.namespace.LOG_TRANSITIONS) {
|
|
31
27
|
// eslint-disable-next-line no-console
|
|
32
28
|
console.log(`Transitioned into '${EmberRouter._routePath(infos)}'`);
|
|
@@ -34,10 +30,9 @@ 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) {
|
|
35
|
+
// @ts-expect-error namespace isn't public
|
|
41
36
|
if (this.namespace.LOG_TRANSITIONS) {
|
|
42
37
|
// eslint-disable-next-line no-console
|
|
43
38
|
console.log(`Preparing to transition from '${EmberRouter._routePath(oldInfos)}' to '${EmberRouter._routePath(newInfos)}'`);
|
|
@@ -76,7 +71,7 @@ const {
|
|
|
76
71
|
@public
|
|
77
72
|
*/
|
|
78
73
|
|
|
79
|
-
class EmberRouter extends EmberObject {
|
|
74
|
+
class EmberRouter extends EmberObject.extend(Evented) {
|
|
80
75
|
constructor(owner) {
|
|
81
76
|
super(...arguments);
|
|
82
77
|
this._didSetupRouter = false;
|
|
@@ -105,6 +100,88 @@ class EmberRouter extends EmberObject {
|
|
|
105
100
|
assert('BUG: RouterService should always be present', routerService !== undefined);
|
|
106
101
|
this._routerService = routerService;
|
|
107
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
The `Router.map` function allows you to define mappings from URLs to routes
|
|
105
|
+
in your application. These mappings are defined within the
|
|
106
|
+
supplied callback function using `this.route`.
|
|
107
|
+
The first parameter is the name of the route which is used by default as the
|
|
108
|
+
path name as well.
|
|
109
|
+
The second parameter is the optional options hash. Available options are:
|
|
110
|
+
* `path`: allows you to provide your own path as well as mark dynamic
|
|
111
|
+
segments.
|
|
112
|
+
* `resetNamespace`: false by default; when nesting routes, ember will
|
|
113
|
+
combine the route names to form the fully-qualified route name, which is
|
|
114
|
+
used with `{{link-to}}` or manually transitioning to routes. Setting
|
|
115
|
+
`resetNamespace: true` will cause the route not to inherit from its
|
|
116
|
+
parent route's names. This is handy for preventing extremely long route names.
|
|
117
|
+
Keep in mind that the actual URL path behavior is still retained.
|
|
118
|
+
The third parameter is a function, which can be used to nest routes.
|
|
119
|
+
Nested routes, by default, will have the parent route tree's route name and
|
|
120
|
+
path prepended to it's own.
|
|
121
|
+
```app/router.js
|
|
122
|
+
Router.map(function(){
|
|
123
|
+
this.route('post', { path: '/post/:post_id' }, function() {
|
|
124
|
+
this.route('edit');
|
|
125
|
+
this.route('comments', { resetNamespace: true }, function() {
|
|
126
|
+
this.route('new');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
@method map
|
|
132
|
+
@param callback
|
|
133
|
+
@public
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
static map(callback) {
|
|
138
|
+
if (!this.dslCallbacks) {
|
|
139
|
+
this.dslCallbacks = []; // FIXME: Can we remove this?
|
|
140
|
+
|
|
141
|
+
this.reopenClass({
|
|
142
|
+
dslCallbacks: this.dslCallbacks
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.dslCallbacks.push(callback);
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static _routePath(routeInfos) {
|
|
151
|
+
let path = []; // We have to handle coalescing resource names that
|
|
152
|
+
// are prefixed with their parent's names, e.g.
|
|
153
|
+
// ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz'
|
|
154
|
+
|
|
155
|
+
function intersectionMatches(a1, a2) {
|
|
156
|
+
for (let i = 0; i < a1.length; ++i) {
|
|
157
|
+
if (a1[i] !== a2[i]) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let name, nameParts, oldNameParts;
|
|
166
|
+
|
|
167
|
+
for (let i = 1; i < routeInfos.length; i++) {
|
|
168
|
+
name = routeInfos[i].name;
|
|
169
|
+
nameParts = name.split('.');
|
|
170
|
+
oldNameParts = slice.call(path);
|
|
171
|
+
|
|
172
|
+
while (oldNameParts.length) {
|
|
173
|
+
if (intersectionMatches(oldNameParts, nameParts)) {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
oldNameParts.shift();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
path.push(...nameParts.slice(oldNameParts.length));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return path.join('.');
|
|
184
|
+
}
|
|
108
185
|
|
|
109
186
|
_initRouterJs() {
|
|
110
187
|
let location = get(this, 'location');
|
|
@@ -129,6 +206,7 @@ class EmberRouter extends EmberObject {
|
|
|
129
206
|
let route = routeOwner.lookup(fullRouteName);
|
|
130
207
|
|
|
131
208
|
if (seen[name]) {
|
|
209
|
+
assert('seen routes should exist', route);
|
|
132
210
|
return route;
|
|
133
211
|
}
|
|
134
212
|
|
|
@@ -172,42 +250,18 @@ class EmberRouter extends EmberObject {
|
|
|
172
250
|
location.setURL(path);
|
|
173
251
|
set(router, 'currentURL', path);
|
|
174
252
|
});
|
|
175
|
-
}
|
|
253
|
+
} // TODO: merge into routeDidChange
|
|
176
254
|
|
|
177
|
-
didTransition(infos) {
|
|
178
|
-
if (ROUTER_EVENTS) {
|
|
179
|
-
if (router.didTransition !== defaultDidTransition) {
|
|
180
|
-
deprecate('You attempted to override the "didTransition" method which is deprecated. Please inject the router service and listen to the "routeDidChange" event.', false, {
|
|
181
|
-
id: 'deprecate-router-events',
|
|
182
|
-
until: '4.0.0',
|
|
183
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_deprecate-router-events',
|
|
184
|
-
for: 'ember-source',
|
|
185
|
-
since: {
|
|
186
|
-
enabled: '3.11.0'
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
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);
|
|
192
258
|
router.didTransition(infos);
|
|
193
|
-
}
|
|
259
|
+
} // TODO: merge into routeWillChange
|
|
194
260
|
|
|
195
|
-
willTransition(oldInfos, newInfos, transition) {
|
|
196
|
-
if (ROUTER_EVENTS) {
|
|
197
|
-
if (router.willTransition !== defaultWillTransition) {
|
|
198
|
-
deprecate('You attempted to override the "willTransition" method which is deprecated. Please inject the router service and listen to the "routeWillChange" event.', false, {
|
|
199
|
-
id: 'deprecate-router-events',
|
|
200
|
-
until: '4.0.0',
|
|
201
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_deprecate-router-events',
|
|
202
|
-
for: 'ember-source',
|
|
203
|
-
since: {
|
|
204
|
-
enabled: '3.11.0'
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
261
|
|
|
210
|
-
|
|
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);
|
|
211
265
|
}
|
|
212
266
|
|
|
213
267
|
triggerEvent(routeInfos, ignoreFailure, name, args) {
|
|
@@ -450,7 +504,14 @@ class EmberRouter extends EmberObject {
|
|
|
450
504
|
if (!this._toplevelView) {
|
|
451
505
|
let owner = getOwner(this);
|
|
452
506
|
let OutletView = owner.factoryFor('view:-outlet');
|
|
453
|
-
|
|
507
|
+
let application = owner.lookup('application:main');
|
|
508
|
+
let environment = owner.lookup('-environment:main');
|
|
509
|
+
let template = owner.lookup('template:-outlet');
|
|
510
|
+
this._toplevelView = OutletView.create({
|
|
511
|
+
environment,
|
|
512
|
+
template,
|
|
513
|
+
application
|
|
514
|
+
});
|
|
454
515
|
|
|
455
516
|
this._toplevelView.setOutletState(liveRoutes);
|
|
456
517
|
|
|
@@ -520,6 +581,7 @@ class EmberRouter extends EmberObject {
|
|
|
520
581
|
|
|
521
582
|
if (this.namespace.LOG_TRANSITIONS) {
|
|
522
583
|
// eslint-disable-next-line no-console
|
|
584
|
+
assert('expected infos to be set', infos);
|
|
523
585
|
console.log(`Intermediate-transitioned into '${EmberRouter._routePath(infos)}'`);
|
|
524
586
|
}
|
|
525
587
|
}
|
|
@@ -532,6 +594,7 @@ class EmberRouter extends EmberObject {
|
|
|
532
594
|
generate(name, ...args) {
|
|
533
595
|
let url = this._routerMicrolib.generate(name, ...args);
|
|
534
596
|
|
|
597
|
+
assert('expected non-string location', typeof this.location !== 'string');
|
|
535
598
|
return this.location.formatURL(url);
|
|
536
599
|
}
|
|
537
600
|
/**
|
|
@@ -603,8 +666,7 @@ class EmberRouter extends EmberObject {
|
|
|
603
666
|
this._toplevelView = null;
|
|
604
667
|
}
|
|
605
668
|
|
|
606
|
-
|
|
607
|
-
|
|
669
|
+
super.willDestroy();
|
|
608
670
|
this.reset();
|
|
609
671
|
let instances = this._engineInstances;
|
|
610
672
|
|
|
@@ -804,7 +866,7 @@ class EmberRouter extends EmberObject {
|
|
|
804
866
|
|
|
805
867
|
this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams);
|
|
806
868
|
|
|
807
|
-
assign(queryParams, _queryParams);
|
|
869
|
+
Object.assign(queryParams, _queryParams);
|
|
808
870
|
|
|
809
871
|
this._prepareQueryParams(targetRouteName, models, queryParams, Boolean(_keepDefaultQueryParamValues));
|
|
810
872
|
|
|
@@ -840,7 +902,7 @@ class EmberRouter extends EmberObject {
|
|
|
840
902
|
|
|
841
903
|
this._fullyScopeQueryParams(targetRouteName, models, unchangedQPs);
|
|
842
904
|
|
|
843
|
-
assign(queryParams, unchangedQPs);
|
|
905
|
+
Object.assign(queryParams, unchangedQPs);
|
|
844
906
|
}
|
|
845
907
|
/**
|
|
846
908
|
Prepares the query params for a URL or Transition. Restores any undefined QP
|
|
@@ -934,7 +996,7 @@ class EmberRouter extends EmberObject {
|
|
|
934
996
|
qps.push(qp);
|
|
935
997
|
}
|
|
936
998
|
|
|
937
|
-
assign(map, qpMeta.map);
|
|
999
|
+
Object.assign(map, qpMeta.map);
|
|
938
1000
|
}
|
|
939
1001
|
|
|
940
1002
|
let finalQPMeta = {
|
|
@@ -1323,7 +1385,8 @@ export function triggerEvent(routeInfos, ignoreFailure, name, args) {
|
|
|
1323
1385
|
if (!routeInfos) {
|
|
1324
1386
|
if (ignoreFailure) {
|
|
1325
1387
|
return;
|
|
1326
|
-
}
|
|
1388
|
+
} // TODO: update?
|
|
1389
|
+
|
|
1327
1390
|
|
|
1328
1391
|
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.`);
|
|
1329
1392
|
}
|
|
@@ -1393,7 +1456,9 @@ function updatePaths(router) {
|
|
|
1393
1456
|
let path = EmberRouter._routePath(infos);
|
|
1394
1457
|
|
|
1395
1458
|
let currentRouteName = infos[infos.length - 1].name;
|
|
1396
|
-
let
|
|
1459
|
+
let location = router.location;
|
|
1460
|
+
assert('expected location to not be a string', typeof location !== 'string');
|
|
1461
|
+
let currentURL = location.getURL();
|
|
1397
1462
|
set(router, 'currentPath', path);
|
|
1398
1463
|
set(router, 'currentRouteName', currentRouteName);
|
|
1399
1464
|
set(router, 'currentURL', currentURL);
|
|
@@ -1405,133 +1470,8 @@ function updatePaths(router) {
|
|
|
1405
1470
|
// actually been entered at that point.
|
|
1406
1471
|
return;
|
|
1407
1472
|
}
|
|
1408
|
-
|
|
1409
|
-
if (APP_CTRL_ROUTER_PROPS) {
|
|
1410
|
-
if (!('currentPath' in appController)) {
|
|
1411
|
-
Object.defineProperty(appController, 'currentPath', {
|
|
1412
|
-
get() {
|
|
1413
|
-
deprecate('Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.', false, {
|
|
1414
|
-
id: 'application-controller.router-properties',
|
|
1415
|
-
until: '4.0.0',
|
|
1416
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_application-controller-router-properties',
|
|
1417
|
-
for: 'ember-source',
|
|
1418
|
-
since: {
|
|
1419
|
-
enabled: '3.10.0-beta.1'
|
|
1420
|
-
}
|
|
1421
|
-
});
|
|
1422
|
-
return get(router, 'currentPath');
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
});
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
notifyPropertyChange(appController, 'currentPath');
|
|
1429
|
-
|
|
1430
|
-
if (!('currentRouteName' in appController)) {
|
|
1431
|
-
Object.defineProperty(appController, 'currentRouteName', {
|
|
1432
|
-
get() {
|
|
1433
|
-
deprecate('Accessing `currentRouteName` on `controller:application` is deprecated, use the `currentRouteName` property on `service:router` instead.', false, {
|
|
1434
|
-
id: 'application-controller.router-properties',
|
|
1435
|
-
until: '4.0.0',
|
|
1436
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_application-controller-router-properties',
|
|
1437
|
-
for: 'ember-source',
|
|
1438
|
-
since: {
|
|
1439
|
-
enabled: '3.10.0-beta.1'
|
|
1440
|
-
}
|
|
1441
|
-
});
|
|
1442
|
-
return get(router, 'currentRouteName');
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
});
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
notifyPropertyChange(appController, 'currentRouteName');
|
|
1449
|
-
}
|
|
1450
1473
|
}
|
|
1451
1474
|
|
|
1452
|
-
EmberRouter.reopenClass({
|
|
1453
|
-
/**
|
|
1454
|
-
The `Router.map` function allows you to define mappings from URLs to routes
|
|
1455
|
-
in your application. These mappings are defined within the
|
|
1456
|
-
supplied callback function using `this.route`.
|
|
1457
|
-
The first parameter is the name of the route which is used by default as the
|
|
1458
|
-
path name as well.
|
|
1459
|
-
The second parameter is the optional options hash. Available options are:
|
|
1460
|
-
* `path`: allows you to provide your own path as well as mark dynamic
|
|
1461
|
-
segments.
|
|
1462
|
-
* `resetNamespace`: false by default; when nesting routes, ember will
|
|
1463
|
-
combine the route names to form the fully-qualified route name, which is
|
|
1464
|
-
used with `{{link-to}}` or manually transitioning to routes. Setting
|
|
1465
|
-
`resetNamespace: true` will cause the route not to inherit from its
|
|
1466
|
-
parent route's names. This is handy for preventing extremely long route names.
|
|
1467
|
-
Keep in mind that the actual URL path behavior is still retained.
|
|
1468
|
-
The third parameter is a function, which can be used to nest routes.
|
|
1469
|
-
Nested routes, by default, will have the parent route tree's route name and
|
|
1470
|
-
path prepended to it's own.
|
|
1471
|
-
```app/router.js
|
|
1472
|
-
Router.map(function(){
|
|
1473
|
-
this.route('post', { path: '/post/:post_id' }, function() {
|
|
1474
|
-
this.route('edit');
|
|
1475
|
-
this.route('comments', { resetNamespace: true }, function() {
|
|
1476
|
-
this.route('new');
|
|
1477
|
-
});
|
|
1478
|
-
});
|
|
1479
|
-
});
|
|
1480
|
-
```
|
|
1481
|
-
@method map
|
|
1482
|
-
@param callback
|
|
1483
|
-
@public
|
|
1484
|
-
*/
|
|
1485
|
-
map(callback) {
|
|
1486
|
-
if (!this.dslCallbacks) {
|
|
1487
|
-
this.dslCallbacks = [];
|
|
1488
|
-
this.reopenClass({
|
|
1489
|
-
dslCallbacks: this.dslCallbacks
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
this.dslCallbacks.push(callback);
|
|
1494
|
-
return this;
|
|
1495
|
-
},
|
|
1496
|
-
|
|
1497
|
-
_routePath(routeInfos) {
|
|
1498
|
-
let path = []; // We have to handle coalescing resource names that
|
|
1499
|
-
// are prefixed with their parent's names, e.g.
|
|
1500
|
-
// ['foo', 'foo.bar.baz'] => 'foo.bar.baz', not 'foo.foo.bar.baz'
|
|
1501
|
-
|
|
1502
|
-
function intersectionMatches(a1, a2) {
|
|
1503
|
-
for (let i = 0; i < a1.length; ++i) {
|
|
1504
|
-
if (a1[i] !== a2[i]) {
|
|
1505
|
-
return false;
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
return true;
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
let name, nameParts, oldNameParts;
|
|
1513
|
-
|
|
1514
|
-
for (let i = 1; i < routeInfos.length; i++) {
|
|
1515
|
-
name = routeInfos[i].name;
|
|
1516
|
-
nameParts = name.split('.');
|
|
1517
|
-
oldNameParts = slice.call(path);
|
|
1518
|
-
|
|
1519
|
-
while (oldNameParts.length) {
|
|
1520
|
-
if (intersectionMatches(oldNameParts, nameParts)) {
|
|
1521
|
-
break;
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
oldNameParts.shift();
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
path.push(...nameParts.slice(oldNameParts.length));
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
return path.join('.');
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
});
|
|
1534
|
-
|
|
1535
1475
|
function didBeginTransition(transition, router) {
|
|
1536
1476
|
let routerState = new RouterState(router, router._routerMicrolib, transition[STATE_SYMBOL]);
|
|
1537
1477
|
|
|
@@ -1639,76 +1579,12 @@ function representEmptyRoute(liveRoutes, defaultParentState, {
|
|
|
1639
1579
|
}
|
|
1640
1580
|
}
|
|
1641
1581
|
|
|
1642
|
-
EmberRouter.reopen(
|
|
1643
|
-
/**
|
|
1644
|
-
Handles updating the paths and notifying any listeners of the URL
|
|
1645
|
-
change.
|
|
1646
|
-
Triggers the router level `didTransition` hook.
|
|
1647
|
-
For example, to notify google analytics when the route changes,
|
|
1648
|
-
you could use this hook. (Note: requires also including GA scripts, etc.)
|
|
1649
|
-
```javascript
|
|
1650
|
-
import config from './config/environment';
|
|
1651
|
-
import EmberRouter from '@ember/routing/router';
|
|
1652
|
-
import { inject as service } from '@ember/service';
|
|
1653
|
-
let Router = EmberRouter.extend({
|
|
1654
|
-
location: config.locationType,
|
|
1655
|
-
router: service(),
|
|
1656
|
-
didTransition: function() {
|
|
1657
|
-
this._super(...arguments);
|
|
1658
|
-
ga('send', 'pageview', {
|
|
1659
|
-
page: this.router.currentURL,
|
|
1660
|
-
title: this.router.currentRouteName,
|
|
1661
|
-
});
|
|
1662
|
-
}
|
|
1663
|
-
});
|
|
1664
|
-
```
|
|
1665
|
-
@method didTransition
|
|
1666
|
-
@public
|
|
1667
|
-
@since 1.2.0
|
|
1668
|
-
*/
|
|
1582
|
+
EmberRouter.reopen({
|
|
1669
1583
|
didTransition: defaultDidTransition,
|
|
1670
|
-
|
|
1671
|
-
/**
|
|
1672
|
-
Handles notifying any listeners of an impending URL
|
|
1673
|
-
change.
|
|
1674
|
-
Triggers the router level `willTransition` hook.
|
|
1675
|
-
@method willTransition
|
|
1676
|
-
@public
|
|
1677
|
-
@since 1.11.0
|
|
1678
|
-
*/
|
|
1679
1584
|
willTransition: defaultWillTransition,
|
|
1680
|
-
|
|
1681
|
-
/**
|
|
1682
|
-
Represents the URL of the root of the application, often '/'. This prefix is
|
|
1683
|
-
assumed on all routes defined on this router.
|
|
1684
|
-
@property rootURL
|
|
1685
|
-
@default '/'
|
|
1686
|
-
@public
|
|
1687
|
-
*/
|
|
1688
1585
|
rootURL: '/',
|
|
1689
|
-
|
|
1690
|
-
/**
|
|
1691
|
-
The `location` property determines the type of URL's that your
|
|
1692
|
-
application will use.
|
|
1693
|
-
The following location types are currently available:
|
|
1694
|
-
* `history` - use the browser's history API to make the URLs look just like any standard URL
|
|
1695
|
-
* `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new`
|
|
1696
|
-
* `none` - do not store the Ember URL in the actual browser URL (mainly used for testing)
|
|
1697
|
-
* `auto` - use the best option based on browser capabilities: `history` if possible, then `hash` if possible, otherwise `none`
|
|
1698
|
-
This value is defaulted to `auto` by the `locationType` setting of `/config/environment.js`
|
|
1699
|
-
@property location
|
|
1700
|
-
@default 'hash'
|
|
1701
|
-
@see {Location}
|
|
1702
|
-
@public
|
|
1703
|
-
*/
|
|
1704
1586
|
location: 'hash',
|
|
1705
|
-
|
|
1706
|
-
/**
|
|
1707
|
-
Represents the current URL.
|
|
1708
|
-
@property url
|
|
1709
|
-
@type {String}
|
|
1710
|
-
@private
|
|
1711
|
-
*/
|
|
1587
|
+
// FIXME: Does this need to be overrideable via extend?
|
|
1712
1588
|
url: computed(function () {
|
|
1713
1589
|
let location = get(this, 'location');
|
|
1714
1590
|
|
|
@@ -1719,9 +1595,4 @@ EmberRouter.reopen(Evented, {
|
|
|
1719
1595
|
return location.getURL();
|
|
1720
1596
|
})
|
|
1721
1597
|
});
|
|
1722
|
-
|
|
1723
|
-
if (ROUTER_EVENTS) {
|
|
1724
|
-
EmberRouter.reopen(ROUTER_EVENT_DEPRECATIONS);
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
1598
|
export default EmberRouter;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { assign } from '@ember/polyfills';
|
|
2
1
|
import { shallowEqual } from '../utils';
|
|
3
2
|
export default class RouterState {
|
|
4
3
|
constructor(emberRouter, router, routerJsState) {
|
|
@@ -15,7 +14,7 @@ export default class RouterState {
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
if (queryParams !== undefined && Object.keys(queryParams).length > 0) {
|
|
18
|
-
let visibleQueryParams = assign({}, queryParams);
|
|
17
|
+
let visibleQueryParams = Object.assign({}, queryParams);
|
|
19
18
|
|
|
20
19
|
this.emberRouter._prepareQueryParams(routeName, models, visibleQueryParams);
|
|
21
20
|
|
|
@@ -2,7 +2,6 @@ import { get } from '@ember/-internals/metal';
|
|
|
2
2
|
import { getOwner } from '@ember/-internals/owner';
|
|
3
3
|
import { deprecate } from '@ember/debug';
|
|
4
4
|
import EmberError from '@ember/error';
|
|
5
|
-
import { assign } from '@ember/polyfills';
|
|
6
5
|
import { STATE_SYMBOL } from 'router_js';
|
|
7
6
|
const ALL_PERIODS_REGEX = /\./g;
|
|
8
7
|
export function extractRouteArgs(args) {
|
|
@@ -190,7 +189,7 @@ function accumulateQueryParamDescriptors(_desc, accum) {
|
|
|
190
189
|
as: null,
|
|
191
190
|
scope: 'model'
|
|
192
191
|
};
|
|
193
|
-
assign(tmp, singleDesc);
|
|
192
|
+
Object.assign(tmp, singleDesc);
|
|
194
193
|
accum[key] = tmp;
|
|
195
194
|
}
|
|
196
195
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { default as Object, FrameworkObject } from './lib/system/object';
|
|
2
2
|
export { default as RegistryProxyMixin } from './lib/mixins/registry_proxy';
|
|
3
3
|
export { default as ContainerProxyMixin } from './lib/mixins/container_proxy';
|
|
4
|
-
export { default as copy } from './lib/copy';
|
|
5
4
|
export { default as compare } from './lib/compare';
|
|
6
5
|
export { default as isEqual } from './lib/is-equal';
|
|
7
6
|
export { default as Array, NativeArray, A, MutableArray, removeAt, uniqBy, isArray } from './lib/mixins/array';
|
|
@@ -11,7 +10,6 @@ export { default as ArrayProxy } from './lib/system/array_proxy';
|
|
|
11
10
|
export { default as ObjectProxy } from './lib/system/object_proxy';
|
|
12
11
|
export { default as CoreObject } from './lib/system/core_object';
|
|
13
12
|
export { default as ActionHandler } from './lib/mixins/action_handler';
|
|
14
|
-
export { default as Copyable } from './lib/mixins/copyable';
|
|
15
13
|
export { default as Enumerable } from './lib/mixins/enumerable';
|
|
16
14
|
export { default as _ProxyMixin, contentFor as _contentFor } from './lib/mixins/-proxy';
|
|
17
15
|
export { default as Observable } from './lib/mixins/observable';
|
|
@@ -21,5 +19,4 @@ export { default as Evented } from './lib/mixins/evented';
|
|
|
21
19
|
export { default as PromiseProxyMixin } from './lib/mixins/promise_proxy';
|
|
22
20
|
export { default as RSVP, onerrorDefault } from './lib/ext/rsvp'; // just for side effect of extending Ember.RSVP
|
|
23
21
|
|
|
24
|
-
export { typeOf } from './lib/type-of';
|
|
25
|
-
import './lib/ext/function'; // just for side effect of extending Function.prototype
|
|
22
|
+
export { typeOf } from './lib/type-of';
|