ember-source 4.8.0-alpha.5 → 4.8.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -2
- package/blueprints/helper/files/__root__/{__collection__ → helpers}/__name__.ts +0 -0
- package/blueprints/helper/index.js +0 -15
- package/blueprints/helper-test/index.js +0 -3
- package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints/helper-test/mocha-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.ts +0 -0
- package/blueprints/helper-test/qunit-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.ts +0 -0
- package/blueprints-js/helper/files/__root__/{__collection__ → helpers}/__name__.js +0 -0
- package/blueprints-js/helper-test/mocha-0.12-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints-js/helper-test/mocha-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints-js/helper-test/qunit-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +1 -1
- package/dist/ember-template-compiler.js +675 -18
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +11 -11
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +19576 -20510
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/glimmer/index.js +4 -2
- package/dist/packages/@ember/-internals/metal/index.js +214 -1094
- package/dist/packages/@ember/-internals/routing/index.js +1 -17
- package/dist/packages/@ember/-internals/runtime/index.js +3 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +2 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +4 -3
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +1 -8
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +2 -1
- package/dist/packages/@ember/-internals/utils/index.js +3 -3
- package/dist/packages/@ember/-internals/views/lib/component_lookup.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +2 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +2 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +2 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/view_state_support.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +2 -1
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/views/core_view.js +3 -1
- package/dist/packages/@ember/application/index.js +876 -2
- package/dist/packages/@ember/application/instance.js +2 -2
- package/dist/packages/@ember/application/namespace.js +70 -1
- package/dist/packages/@ember/array/index.js +1503 -2
- package/dist/packages/@ember/array/mutable.js +1 -1
- package/dist/packages/@ember/array/proxy.js +307 -1
- package/dist/packages/@ember/canary-features/index.js +2 -2
- package/dist/packages/@ember/controller/index.js +260 -3
- package/dist/packages/@ember/debug/container-debug-adapter.js +99 -1
- package/dist/packages/@ember/debug/data-adapter.js +574 -1
- package/dist/packages/@ember/engine/index.js +5 -5
- package/dist/packages/@ember/engine/instance.js +4 -4
- package/dist/packages/@ember/enumerable/index.js +3 -1
- package/dist/packages/@ember/enumerable/mutable.js +4 -0
- package/dist/packages/@ember/{-internals/runtime/lib/system/object.js → object/-internals.js} +4 -17
- package/dist/packages/@ember/object/core.js +731 -1
- package/dist/packages/@ember/object/evented.js +93 -2
- package/dist/packages/@ember/object/index.js +76 -4
- package/dist/packages/@ember/object/internals.js +3 -2
- package/dist/packages/@ember/object/lib/computed/computed_macros.js +3 -1
- package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +4 -3
- package/dist/packages/@ember/object/mixin.js +659 -1
- package/dist/packages/@ember/object/observable.js +341 -1
- package/dist/packages/@ember/object/promise-proxy-mixin.js +150 -1
- package/dist/packages/@ember/object/proxy.js +10 -1
- package/dist/packages/@ember/routing/-internals.js +7 -0
- package/dist/packages/@ember/routing/auto-location.js +249 -1
- package/dist/packages/@ember/routing/hash-location.js +169 -1
- package/dist/packages/@ember/routing/history-location.js +289 -1
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/cache.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/controller_for.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/dsl.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/engines.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/generate_controller.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/location/util.js → routing/lib/location-utils.js} +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/query_params.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/route-info.js +0 -0
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/router_state.js +1 -1
- package/dist/packages/@ember/{-internals/routing/lib/services/routing.js → routing/lib/routing-service.js} +2 -2
- package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/transition.js +0 -0
- package/dist/packages/@ember/{-internals/routing → routing}/lib/utils.js +0 -0
- package/dist/packages/@ember/routing/location.js +104 -1
- package/dist/packages/@ember/routing/none-location.js +123 -1
- package/dist/packages/@ember/routing/route.js +1700 -1
- package/dist/packages/@ember/routing/router-service.js +510 -1
- package/dist/packages/@ember/routing/router.js +1666 -1
- package/dist/packages/@ember/service/index.js +1 -1
- package/dist/packages/@ember/utils/index.js +7 -2
- package/dist/packages/@ember/{-internals/runtime → utils}/lib/compare.js +2 -2
- package/dist/packages/@ember/{-internals/runtime → utils}/lib/is-equal.js +0 -0
- package/dist/packages/@ember/utils/lib/is_blank.js +35 -0
- package/dist/packages/@ember/utils/lib/is_empty.js +68 -0
- package/dist/packages/@ember/utils/lib/is_none.js +27 -0
- package/dist/packages/@ember/utils/lib/is_present.js +38 -0
- package/dist/packages/@ember/{-internals/runtime → utils}/lib/type-of.js +2 -2
- package/dist/packages/ember/index.js +47 -28
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/lib/adapters/adapter.js +1 -1
- package/dist/packages/ember-testing/lib/helpers/current_path.js +2 -2
- package/dist/packages/ember-testing/lib/helpers/current_route_name.js +2 -2
- package/dist/packages/ember-testing/lib/helpers/current_url.js +1 -1
- package/docs/data.json +9428 -9189
- package/package.json +23 -8
- package/types/preview/@ember/-internals/resolver.d.ts +35 -0
- package/types/preview/@ember/application/-private/event-dispatcher.d.ts +18 -0
- package/types/preview/@ember/application/-private/registry.d.ts +15 -0
- package/types/preview/@ember/application/deprecations.d.ts +24 -0
- package/types/preview/@ember/application/index.d.ts +153 -0
- package/types/preview/@ember/application/instance.d.ts +9 -0
- package/types/preview/@ember/application/tsconfig.json +3 -0
- package/types/preview/@ember/application/types.d.ts +29 -0
- package/types/preview/@ember/array/-private/enumerable.d.ts +13 -0
- package/types/preview/@ember/array/-private/mutable-enumerable.d.ts +13 -0
- package/types/preview/@ember/array/-private/native-array.d.ts +23 -0
- package/types/preview/@ember/array/index.d.ts +243 -0
- package/types/preview/@ember/array/mutable.d.ts +94 -0
- package/types/preview/@ember/array/proxy.d.ts +29 -0
- package/types/preview/@ember/array/tsconfig.json +3 -0
- package/types/preview/@ember/component/-private/class-names-support.d.ts +27 -0
- package/types/preview/@ember/component/-private/core-view.d.ts +14 -0
- package/types/preview/@ember/component/-private/glimmer-interfaces.d.ts +45 -0
- package/types/preview/@ember/component/-private/signature-utils.d.ts +107 -0
- package/types/preview/@ember/component/-private/view-mixin.d.ts +59 -0
- package/types/preview/@ember/component/helper.d.ts +122 -0
- package/types/preview/@ember/component/index.d.ts +132 -0
- package/types/preview/@ember/component/template-only.d.ts +47 -0
- package/types/preview/@ember/component/tsconfig.json +3 -0
- package/types/preview/@ember/controller/index.d.ts +48 -0
- package/types/preview/@ember/controller/tsconfig.json +3 -0
- package/types/preview/@ember/debug/container-debug-adapter.d.ts +13 -0
- package/types/preview/@ember/debug/data-adapter.d.ts +64 -0
- package/types/preview/@ember/debug/index.d.ts +98 -0
- package/types/preview/@ember/debug/tsconfig.json +3 -0
- package/types/preview/@ember/destroyable/index.d.ts +23 -0
- package/types/preview/@ember/destroyable/tsconfig.json +3 -0
- package/types/preview/@ember/engine/-private/container-proxy-mixin.d.ts +17 -0
- package/types/preview/@ember/engine/-private/registry-proxy-mixin.d.ts +54 -0
- package/types/preview/@ember/engine/-private/types/initializer.d.ts +8 -0
- package/types/preview/@ember/engine/index.d.ts +45 -0
- package/types/preview/@ember/engine/instance.d.ts +24 -0
- package/types/preview/@ember/engine/tsconfig.json +3 -0
- package/types/preview/@ember/error/index.d.ts +6 -0
- package/types/preview/@ember/error/tsconfig.json +3 -0
- package/types/preview/@ember/helper/index.d.ts +49 -0
- package/types/preview/@ember/helper/tsconfig.json +3 -0
- package/types/preview/@ember/modifier/index.d.ts +33 -0
- package/types/preview/@ember/modifier/tsconfig.json +3 -0
- package/types/preview/@ember/object/-private/action-handler.d.ts +31 -0
- package/types/preview/@ember/object/-private/types.d.ts +63 -0
- package/types/preview/@ember/object/compat.d.ts +9 -0
- package/types/preview/@ember/object/computed.d.ts +263 -0
- package/types/preview/@ember/object/core.d.ts +89 -0
- package/types/preview/@ember/object/evented.d.ts +45 -0
- package/types/preview/@ember/object/events.d.ts +47 -0
- package/types/preview/@ember/object/index.d.ts +126 -0
- package/types/preview/@ember/object/internals.d.ts +17 -0
- package/types/preview/@ember/object/mixin.d.ts +19 -0
- package/types/preview/@ember/object/observable.d.ts +89 -0
- package/types/preview/@ember/object/observers.d.ts +34 -0
- package/types/preview/@ember/object/promise-proxy-mixin.d.ts +37 -0
- package/types/preview/@ember/object/proxy.d.ts +27 -0
- package/types/preview/@ember/object/tsconfig.json +3 -0
- package/types/preview/@ember/owner/index.d.ts +102 -0
- package/types/preview/@ember/owner/tsconfig.json +3 -0
- package/types/preview/@ember/polyfills/index.d.ts +23 -0
- package/types/preview/@ember/polyfills/tsconfig.json +3 -0
- package/types/preview/@ember/polyfills/types.d.ts +6 -0
- package/types/preview/@ember/routing/-private/router-dsl.d.ts +20 -0
- package/types/preview/@ember/routing/auto-location.d.ts +8 -0
- package/types/preview/@ember/routing/hash-location.d.ts +10 -0
- package/types/preview/@ember/routing/history-location.d.ts +9 -0
- package/types/preview/@ember/routing/index.d.ts +20 -0
- package/types/preview/@ember/routing/none-location.d.ts +11 -0
- package/types/preview/@ember/routing/route-info.d.ts +74 -0
- package/types/preview/@ember/routing/route.d.ts +533 -0
- package/types/preview/@ember/routing/router-service.d.ts +351 -0
- package/types/preview/@ember/routing/router.d.ts +49 -0
- package/types/preview/@ember/routing/transition.d.ts +126 -0
- package/types/preview/@ember/routing/tsconfig.json +3 -0
- package/types/preview/@ember/routing/types.d.ts +15 -0
- package/types/preview/@ember/runloop/-private/backburner.d.ts +43 -0
- package/types/preview/@ember/runloop/-private/types.d.ts +9 -0
- package/types/preview/@ember/runloop/index.d.ts +175 -0
- package/types/preview/@ember/runloop/tsconfig.json +3 -0
- package/types/preview/@ember/runloop/types.d.ts +5 -0
- package/types/preview/@ember/service/index.d.ts +25 -0
- package/types/preview/@ember/service/tsconfig.json +3 -0
- package/types/preview/@ember/string/index.d.ts +9 -0
- package/types/preview/@ember/string/tsconfig.json +3 -0
- package/types/preview/@ember/template/-private/handlebars.d.ts +7 -0
- package/types/preview/@ember/template/index.d.ts +5 -0
- package/types/preview/@ember/template/tsconfig.json +3 -0
- package/types/preview/@ember/test/adapter.d.ts +22 -0
- package/types/preview/@ember/test/index.d.ts +49 -0
- package/types/preview/@ember/test/tsconfig.json +3 -0
- package/types/preview/@ember/utils/-private/types.d.ts +39 -0
- package/types/preview/@ember/utils/index.d.ts +42 -0
- package/types/preview/@ember/utils/tsconfig.json +3 -0
- package/types/preview/ember/-private/type-utils.d.ts +54 -0
- package/types/preview/ember/index.d.ts +381 -0
- package/types/preview/ember/tsconfig.json +3 -0
- package/types/preview/index.d.ts +120 -0
- package/types/preview/tsconfig.json +6 -0
- package/blueprints/helper/mu-files/__root__/__collection__/__name__.js +0 -7
- package/blueprints-js/helper/mu-files/__root__/__collection__/__name__.js +0 -7
- package/dist/packages/@ember/-internals/extension-support/index.js +0 -2
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +0 -96
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +0 -576
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +0 -224
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +0 -104
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +0 -250
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +0 -170
- package/dist/packages/@ember/-internals/routing/lib/location/history_location.js +0 -290
- package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +0 -124
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +0 -506
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +0 -1696
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +0 -1662
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +0 -1501
- package/dist/packages/@ember/-internals/runtime/lib/mixins/enumerable.js +0 -3
- package/dist/packages/@ember/-internals/runtime/lib/mixins/evented.js +0 -91
- package/dist/packages/@ember/-internals/runtime/lib/mixins/mutable_enumerable.js +0 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +0 -339
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +0 -149
- package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +0 -305
- package/dist/packages/@ember/-internals/runtime/lib/system/core_object.js +0 -730
- package/dist/packages/@ember/-internals/runtime/lib/system/namespace.js +0 -69
- package/dist/packages/@ember/-internals/runtime/lib/system/object_proxy.js +0 -7
- package/dist/packages/@ember/application/lib/application.js +0 -870
- package/dist/packages/@ember/controller/lib/controller_mixin.js +0 -42
- package/dist/packages/@ember/runloop/type-tests.ts/begin-end.test.js +0 -5
- package/dist/packages/@ember/runloop/type-tests.ts/bind.test.js +0 -59
- package/dist/packages/@ember/runloop/type-tests.ts/cancel.test.js +0 -5
- package/dist/packages/@ember/runloop/type-tests.ts/debounce.test.js +0 -77
- package/dist/packages/@ember/runloop/type-tests.ts/join.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/later.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/next.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/once.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/run.test.js +0 -38
- package/dist/packages/@ember/runloop/type-tests.ts/schedule-once.test.js +0 -39
- package/dist/packages/@ember/runloop/type-tests.ts/schedule.test.js +0 -39
- package/dist/packages/@ember/runloop/type-tests.ts/throttle.test.js +0 -77
|
@@ -1 +1,249 @@
|
|
|
1
|
-
|
|
1
|
+
import { history, location, userAgent, window } from '@ember/-internals/browser-environment';
|
|
2
|
+
import { getOwner } from '@ember/-internals/owner';
|
|
3
|
+
import EmberObject, { set } from '@ember/object';
|
|
4
|
+
import { assert } from '@ember/debug';
|
|
5
|
+
import { getFullPath, getHash, getPath, getQuery, replacePath, supportsHashChange, supportsHistory } from './lib/location-utils';
|
|
6
|
+
/**
|
|
7
|
+
@module @ember/routing/auto-location
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
AutoLocation will select the best location option based off browser
|
|
12
|
+
support with the priority order: history, hash, none.
|
|
13
|
+
|
|
14
|
+
Clean pushState paths accessed by hashchange-only browsers will be redirected
|
|
15
|
+
to the hash-equivalent and vice versa so future transitions are consistent.
|
|
16
|
+
|
|
17
|
+
Keep in mind that since some of your users will use `HistoryLocation`, your
|
|
18
|
+
server must serve the Ember app at all the routes you define.
|
|
19
|
+
|
|
20
|
+
Browsers that support the `history` API will use `HistoryLocation`, those that
|
|
21
|
+
do not, but still support the `hashchange` event will use `HashLocation`, and
|
|
22
|
+
in the rare case neither is supported will use `NoneLocation`.
|
|
23
|
+
|
|
24
|
+
Example:
|
|
25
|
+
|
|
26
|
+
```app/router.js
|
|
27
|
+
Router.map(function() {
|
|
28
|
+
this.route('posts', function() {
|
|
29
|
+
this.route('new');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Router.reopen({
|
|
34
|
+
location: 'auto'
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This will result in a posts.new url of `/posts/new` for modern browsers that
|
|
39
|
+
support the `history` api or `/#/posts/new` for older ones, like Internet
|
|
40
|
+
Explorer 9 and below.
|
|
41
|
+
|
|
42
|
+
When a user visits a link to your application, they will be automatically
|
|
43
|
+
upgraded or downgraded to the appropriate `Location` class, with the URL
|
|
44
|
+
transformed accordingly, if needed.
|
|
45
|
+
|
|
46
|
+
Keep in mind that since some of your users will use `HistoryLocation`, your
|
|
47
|
+
server must serve the Ember app at all the routes you define.
|
|
48
|
+
|
|
49
|
+
@class AutoLocation
|
|
50
|
+
@static
|
|
51
|
+
@protected
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
export default class AutoLocation extends EmberObject {
|
|
55
|
+
constructor() {
|
|
56
|
+
super(...arguments);
|
|
57
|
+
this.implementation = 'auto';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
Called by the router to instruct the location to do any feature detection
|
|
61
|
+
necessary. In the case of AutoLocation, we detect whether to use history
|
|
62
|
+
or hash concrete implementations.
|
|
63
|
+
@private
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
detect() {
|
|
68
|
+
let rootURL = this.rootURL;
|
|
69
|
+
assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/');
|
|
70
|
+
let implementation = detectImplementation({
|
|
71
|
+
location: this.location,
|
|
72
|
+
history: this.history,
|
|
73
|
+
userAgent: this.userAgent,
|
|
74
|
+
rootURL,
|
|
75
|
+
documentMode: this.documentMode,
|
|
76
|
+
global: this.global
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (implementation === false) {
|
|
80
|
+
set(this, 'cancelRouterSetup', true);
|
|
81
|
+
implementation = 'none';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let owner = getOwner(this);
|
|
85
|
+
assert('AutoLocation is unexpectedly missing an owner', owner);
|
|
86
|
+
let concrete = owner.lookup(`location:${implementation}`);
|
|
87
|
+
assert(`Could not find location '${implementation}'.`, concrete !== undefined);
|
|
88
|
+
set(concrete, 'rootURL', rootURL);
|
|
89
|
+
set(this, 'concreteImplementation', concrete);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
willDestroy() {
|
|
93
|
+
let {
|
|
94
|
+
concreteImplementation
|
|
95
|
+
} = this;
|
|
96
|
+
|
|
97
|
+
if (concreteImplementation) {
|
|
98
|
+
concreteImplementation.destroy();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
AutoLocation.reopen({
|
|
104
|
+
rootURL: '/',
|
|
105
|
+
initState: delegateToConcreteImplementation('initState'),
|
|
106
|
+
getURL: delegateToConcreteImplementation('getURL'),
|
|
107
|
+
setURL: delegateToConcreteImplementation('setURL'),
|
|
108
|
+
replaceURL: delegateToConcreteImplementation('replaceURL'),
|
|
109
|
+
onUpdateURL: delegateToConcreteImplementation('onUpdateURL'),
|
|
110
|
+
formatURL: delegateToConcreteImplementation('formatURL'),
|
|
111
|
+
location: location,
|
|
112
|
+
history: history,
|
|
113
|
+
global: window,
|
|
114
|
+
userAgent: userAgent,
|
|
115
|
+
cancelRouterSetup: false
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
function delegateToConcreteImplementation(methodName) {
|
|
119
|
+
return function (...args) {
|
|
120
|
+
var _a;
|
|
121
|
+
|
|
122
|
+
let {
|
|
123
|
+
concreteImplementation
|
|
124
|
+
} = this;
|
|
125
|
+
assert("AutoLocation's detect() method should be called before calling any other hooks.", concreteImplementation); // We need this cast because `Parameters` is deferred so that it is not
|
|
126
|
+
// possible for TS to see it will always produce the right type. However,
|
|
127
|
+
// since `AnyFn` has a rest type, it is allowed. See discussion on [this
|
|
128
|
+
// issue](https://github.com/microsoft/TypeScript/issues/47615).
|
|
129
|
+
|
|
130
|
+
return (_a = concreteImplementation[methodName]) === null || _a === void 0 ? void 0 : _a.call(concreteImplementation, ...args);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function detectImplementation(options) {
|
|
135
|
+
let {
|
|
136
|
+
location,
|
|
137
|
+
userAgent,
|
|
138
|
+
history,
|
|
139
|
+
documentMode,
|
|
140
|
+
global,
|
|
141
|
+
rootURL
|
|
142
|
+
} = options;
|
|
143
|
+
let implementation = 'none';
|
|
144
|
+
let cancelRouterSetup = false;
|
|
145
|
+
let currentPath = getFullPath(location);
|
|
146
|
+
|
|
147
|
+
if (supportsHistory(userAgent, history)) {
|
|
148
|
+
let historyPath = getHistoryPath(rootURL, location); // If the browser supports history and we have a history path, we can use
|
|
149
|
+
// the history location with no redirects.
|
|
150
|
+
|
|
151
|
+
if (currentPath === historyPath) {
|
|
152
|
+
implementation = 'history';
|
|
153
|
+
} else if (currentPath.substring(0, 2) === '/#') {
|
|
154
|
+
history.replaceState({
|
|
155
|
+
path: historyPath
|
|
156
|
+
}, '', historyPath);
|
|
157
|
+
implementation = 'history';
|
|
158
|
+
} else {
|
|
159
|
+
cancelRouterSetup = true;
|
|
160
|
+
replacePath(location, historyPath);
|
|
161
|
+
}
|
|
162
|
+
} else if (supportsHashChange(documentMode, global)) {
|
|
163
|
+
let hashPath = getHashPath(rootURL, location); // Be sure we're using a hashed path, otherwise let's switch over it to so
|
|
164
|
+
// we start off clean and consistent. We'll count an index path with no
|
|
165
|
+
// hash as "good enough" as well.
|
|
166
|
+
|
|
167
|
+
if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') {
|
|
168
|
+
implementation = 'hash';
|
|
169
|
+
} else {
|
|
170
|
+
// Our URL isn't in the expected hash-supported format, so we want to
|
|
171
|
+
// cancel the router setup and replace the URL to start off clean
|
|
172
|
+
cancelRouterSetup = true;
|
|
173
|
+
replacePath(location, hashPath);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (cancelRouterSetup) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return implementation;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
@private
|
|
185
|
+
|
|
186
|
+
Returns the current path as it should appear for HistoryLocation supported
|
|
187
|
+
browsers. This may very well differ from the real current path (e.g. if it
|
|
188
|
+
starts off as a hashed URL)
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
export function getHistoryPath(rootURL, location) {
|
|
193
|
+
let path = getPath(location);
|
|
194
|
+
let hash = getHash(location);
|
|
195
|
+
let query = getQuery(location);
|
|
196
|
+
let rootURLIndex = path.indexOf(rootURL);
|
|
197
|
+
let routeHash;
|
|
198
|
+
let hashParts;
|
|
199
|
+
assert(`Path ${path} does not start with the provided rootURL ${rootURL}`, rootURLIndex === 0); // By convention, Ember.js routes using HashLocation are required to start
|
|
200
|
+
// with `#/`. Anything else should NOT be considered a route and should
|
|
201
|
+
// be passed straight through, without transformation.
|
|
202
|
+
|
|
203
|
+
if (hash.substring(0, 2) === '#/') {
|
|
204
|
+
// There could be extra hash segments after the route
|
|
205
|
+
hashParts = hash.substring(1).split('#'); // The first one is always the route url
|
|
206
|
+
|
|
207
|
+
routeHash = hashParts.shift(); // If the path already has a trailing slash, remove the one
|
|
208
|
+
// from the hashed route so we don't double up.
|
|
209
|
+
|
|
210
|
+
if (path.charAt(path.length - 1) === '/') {
|
|
211
|
+
routeHash = routeHash.substring(1);
|
|
212
|
+
} // This is the "expected" final order
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
path += routeHash + query;
|
|
216
|
+
|
|
217
|
+
if (hashParts.length) {
|
|
218
|
+
path += `#${hashParts.join('#')}`;
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
path += query + hash;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return path;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
@private
|
|
228
|
+
|
|
229
|
+
Returns the current path as it should appear for HashLocation supported
|
|
230
|
+
browsers. This may very well differ from the real current path.
|
|
231
|
+
|
|
232
|
+
@method _getHashPath
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
export function getHashPath(rootURL, location) {
|
|
236
|
+
let path = rootURL;
|
|
237
|
+
let historyPath = getHistoryPath(rootURL, location);
|
|
238
|
+
let routePath = historyPath.substring(rootURL.length);
|
|
239
|
+
|
|
240
|
+
if (routePath !== '') {
|
|
241
|
+
if (routePath[0] !== '/') {
|
|
242
|
+
routePath = `/${routePath}`;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
path += `#${routePath}`;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return path;
|
|
249
|
+
}
|
|
@@ -1 +1,169 @@
|
|
|
1
|
-
|
|
1
|
+
import EmberObject, { set } from '@ember/object';
|
|
2
|
+
import { bind } from '@ember/runloop';
|
|
3
|
+
import { getHash } from './lib/location-utils';
|
|
4
|
+
/**
|
|
5
|
+
@module @ember/routing/hash-location
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
`HashLocation` implements the location API using the browser's
|
|
10
|
+
hash. At present, it relies on a `hashchange` event existing in the
|
|
11
|
+
browser.
|
|
12
|
+
|
|
13
|
+
Using `HashLocation` results in URLs with a `#` (hash sign) separating the
|
|
14
|
+
server side URL portion of the URL from the portion that is used by Ember.
|
|
15
|
+
|
|
16
|
+
Example:
|
|
17
|
+
|
|
18
|
+
```app/router.js
|
|
19
|
+
Router.map(function() {
|
|
20
|
+
this.route('posts', function() {
|
|
21
|
+
this.route('new');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
Router.reopen({
|
|
26
|
+
location: 'hash'
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This will result in a posts.new url of `/#/posts/new`.
|
|
31
|
+
|
|
32
|
+
@class HashLocation
|
|
33
|
+
@extends EmberObject
|
|
34
|
+
@protected
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
export default class HashLocation extends EmberObject {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this.implementation = 'hash';
|
|
41
|
+
this.lastSetURL = null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
init() {
|
|
45
|
+
set(this, 'location', this._location || window.location);
|
|
46
|
+
this._hashchangeHandler = undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
@private
|
|
50
|
+
Returns normalized location.hash
|
|
51
|
+
@since 1.5.1
|
|
52
|
+
@method getHash
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
getHash() {
|
|
57
|
+
return getHash(this.location);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
Returns the normalized URL, constructed from `location.hash`.
|
|
61
|
+
e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`.
|
|
62
|
+
By convention, hashed paths must begin with a forward slash, otherwise they
|
|
63
|
+
are not treated as a path so we can distinguish intent.
|
|
64
|
+
@private
|
|
65
|
+
@method getURL
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
getURL() {
|
|
70
|
+
let originalPath = this.getHash().substring(1);
|
|
71
|
+
let outPath = originalPath;
|
|
72
|
+
|
|
73
|
+
if (outPath[0] !== '/') {
|
|
74
|
+
outPath = '/'; // Only add the # if the path isn't empty.
|
|
75
|
+
// We do NOT want `/#` since the ampersand
|
|
76
|
+
// is only included (conventionally) when
|
|
77
|
+
// the location.hash has a value
|
|
78
|
+
|
|
79
|
+
if (originalPath) {
|
|
80
|
+
outPath += `#${originalPath}`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return outPath;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
Set the `location.hash` and remembers what was set. This prevents
|
|
88
|
+
`onUpdateURL` callbacks from triggering when the hash was set by
|
|
89
|
+
`HashLocation`.
|
|
90
|
+
@private
|
|
91
|
+
@method setURL
|
|
92
|
+
@param path {String}
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
setURL(path) {
|
|
97
|
+
this.location.hash = path;
|
|
98
|
+
set(this, 'lastSetURL', path);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
Uses location.replace to update the url without a page reload
|
|
102
|
+
or history modification.
|
|
103
|
+
@private
|
|
104
|
+
@method replaceURL
|
|
105
|
+
@param path {String}
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
replaceURL(path) {
|
|
110
|
+
this.location.replace(`#${path}`);
|
|
111
|
+
set(this, 'lastSetURL', path);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
Register a callback to be invoked when the hash changes. These
|
|
115
|
+
callbacks will execute when the user presses the back or forward
|
|
116
|
+
button, but not after `setURL` is invoked.
|
|
117
|
+
@private
|
|
118
|
+
@method onUpdateURL
|
|
119
|
+
@param callback {Function}
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
onUpdateURL(callback) {
|
|
124
|
+
this._removeEventListener();
|
|
125
|
+
|
|
126
|
+
this._hashchangeHandler = bind(this, function (_event) {
|
|
127
|
+
let path = this.getURL();
|
|
128
|
+
|
|
129
|
+
if (this.lastSetURL === path) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
set(this, 'lastSetURL', null);
|
|
134
|
+
callback(path);
|
|
135
|
+
});
|
|
136
|
+
window.addEventListener('hashchange', this._hashchangeHandler);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
Given a URL, formats it to be placed into the page as part
|
|
140
|
+
of an element's `href` attribute.
|
|
141
|
+
This is used, for example, when using the {{action}} helper
|
|
142
|
+
to generate a URL based on an event.
|
|
143
|
+
@private
|
|
144
|
+
@method formatURL
|
|
145
|
+
@param url {String}
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
formatURL(url) {
|
|
150
|
+
return `#${url}`;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
Cleans up the HashLocation event listener.
|
|
154
|
+
@private
|
|
155
|
+
@method willDestroy
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
willDestroy() {
|
|
160
|
+
this._removeEventListener();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
_removeEventListener() {
|
|
164
|
+
if (this._hashchangeHandler) {
|
|
165
|
+
window.removeEventListener('hashchange', this._hashchangeHandler);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
|
@@ -1 +1,289 @@
|
|
|
1
|
-
|
|
1
|
+
import EmberObject, { set } from '@ember/object';
|
|
2
|
+
import { getHash } from './lib/location-utils';
|
|
3
|
+
/**
|
|
4
|
+
@module @ember/routing/history-location
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
let popstateFired = false;
|
|
8
|
+
|
|
9
|
+
function _uuid() {
|
|
10
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
11
|
+
let r, v;
|
|
12
|
+
r = Math.random() * 16 | 0;
|
|
13
|
+
v = c === 'x' ? r : r & 3 | 8;
|
|
14
|
+
return v.toString(16);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
HistoryLocation implements the location API using the browser's
|
|
19
|
+
history.pushState API.
|
|
20
|
+
|
|
21
|
+
Using `HistoryLocation` results in URLs that are indistinguishable from a
|
|
22
|
+
standard URL. This relies upon the browser's `history` API.
|
|
23
|
+
|
|
24
|
+
Example:
|
|
25
|
+
|
|
26
|
+
```app/router.js
|
|
27
|
+
Router.map(function() {
|
|
28
|
+
this.route('posts', function() {
|
|
29
|
+
this.route('new');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Router.reopen({
|
|
34
|
+
location: 'history'
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This will result in a posts.new url of `/posts/new`.
|
|
39
|
+
|
|
40
|
+
Keep in mind that your server must serve the Ember app at all the routes you
|
|
41
|
+
define.
|
|
42
|
+
|
|
43
|
+
Using `HistoryLocation` will also result in location states being recorded by
|
|
44
|
+
the browser `history` API with the following schema:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
window.history.state -> { path: '/', uuid: '3552e730-b4a6-46bd-b8bf-d8c3c1a97e0a' }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This allows each in-app location state to be tracked uniquely across history
|
|
51
|
+
state changes via the `uuid` field.
|
|
52
|
+
|
|
53
|
+
@class HistoryLocation
|
|
54
|
+
@extends EmberObject
|
|
55
|
+
@protected
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
export default class HistoryLocation extends EmberObject {
|
|
60
|
+
constructor() {
|
|
61
|
+
super(...arguments);
|
|
62
|
+
this.implementation = 'history';
|
|
63
|
+
/**
|
|
64
|
+
Will be pre-pended to path upon state change
|
|
65
|
+
@property rootURL
|
|
66
|
+
@default '/'
|
|
67
|
+
@private
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
this.rootURL = '/';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
@private
|
|
74
|
+
Returns normalized location.hash
|
|
75
|
+
@method getHash
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
getHash() {
|
|
80
|
+
return getHash(this.location);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
init() {
|
|
84
|
+
var _a;
|
|
85
|
+
|
|
86
|
+
this._super(...arguments);
|
|
87
|
+
|
|
88
|
+
let base = document.querySelector('base');
|
|
89
|
+
let baseURL = '';
|
|
90
|
+
|
|
91
|
+
if (base !== null && base.hasAttribute('href')) {
|
|
92
|
+
baseURL = (_a = base.getAttribute('href')) !== null && _a !== void 0 ? _a : '';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
set(this, 'baseURL', baseURL);
|
|
96
|
+
set(this, 'location', this.location || window.location);
|
|
97
|
+
this._popstateHandler = undefined;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
Used to set state on first call to setURL
|
|
101
|
+
@private
|
|
102
|
+
@method initState
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
initState() {
|
|
107
|
+
let history = this.history || window.history;
|
|
108
|
+
set(this, 'history', history);
|
|
109
|
+
let {
|
|
110
|
+
state
|
|
111
|
+
} = history;
|
|
112
|
+
let path = this.formatURL(this.getURL());
|
|
113
|
+
|
|
114
|
+
if (state && state.path === path) {
|
|
115
|
+
// preserve existing state
|
|
116
|
+
// used for webkit workaround, since there will be no initial popstate event
|
|
117
|
+
this._previousURL = this.getURL();
|
|
118
|
+
} else {
|
|
119
|
+
this.replaceState(path);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
Returns the current `location.pathname` without `rootURL` or `baseURL`
|
|
124
|
+
@private
|
|
125
|
+
@method getURL
|
|
126
|
+
@return url {String}
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
getURL() {
|
|
131
|
+
let {
|
|
132
|
+
location,
|
|
133
|
+
rootURL,
|
|
134
|
+
baseURL
|
|
135
|
+
} = this;
|
|
136
|
+
let path = location.pathname; // remove trailing slashes if they exists
|
|
137
|
+
|
|
138
|
+
rootURL = rootURL.replace(/\/$/, '');
|
|
139
|
+
baseURL = baseURL.replace(/\/$/, ''); // remove baseURL and rootURL from start of path
|
|
140
|
+
|
|
141
|
+
let url = path.replace(new RegExp(`^${baseURL}(?=/|$)`), '').replace(new RegExp(`^${rootURL}(?=/|$)`), '').replace(/\/\//g, '/'); // remove extra slashes
|
|
142
|
+
|
|
143
|
+
let search = location.search || '';
|
|
144
|
+
url += search + this.getHash();
|
|
145
|
+
return url;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
Uses `history.pushState` to update the url without a page reload.
|
|
149
|
+
@private
|
|
150
|
+
@method setURL
|
|
151
|
+
@param path {String}
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
setURL(path) {
|
|
156
|
+
let {
|
|
157
|
+
state
|
|
158
|
+
} = this.history;
|
|
159
|
+
path = this.formatURL(path);
|
|
160
|
+
|
|
161
|
+
if (!state || state.path !== path) {
|
|
162
|
+
this.pushState(path);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
Uses `history.replaceState` to update the url without a page reload
|
|
167
|
+
or history modification.
|
|
168
|
+
@private
|
|
169
|
+
@method replaceURL
|
|
170
|
+
@param path {String}
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
replaceURL(path) {
|
|
175
|
+
let {
|
|
176
|
+
state
|
|
177
|
+
} = this.history;
|
|
178
|
+
path = this.formatURL(path);
|
|
179
|
+
|
|
180
|
+
if (!state || state.path !== path) {
|
|
181
|
+
this.replaceState(path);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
Pushes a new state.
|
|
186
|
+
@private
|
|
187
|
+
@method pushState
|
|
188
|
+
@param path {String}
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
pushState(path) {
|
|
193
|
+
let state = {
|
|
194
|
+
path,
|
|
195
|
+
uuid: _uuid()
|
|
196
|
+
};
|
|
197
|
+
this.history.pushState(state, null, path); // used for webkit workaround
|
|
198
|
+
|
|
199
|
+
this._previousURL = this.getURL();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
Replaces the current state.
|
|
203
|
+
@private
|
|
204
|
+
@method replaceState
|
|
205
|
+
@param path {String}
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
replaceState(path) {
|
|
210
|
+
let state = {
|
|
211
|
+
path,
|
|
212
|
+
uuid: _uuid()
|
|
213
|
+
};
|
|
214
|
+
this.history.replaceState(state, null, path); // used for webkit workaround
|
|
215
|
+
|
|
216
|
+
this._previousURL = this.getURL();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
Register a callback to be invoked whenever the browser
|
|
220
|
+
history changes, including using forward and back buttons.
|
|
221
|
+
@private
|
|
222
|
+
@method onUpdateURL
|
|
223
|
+
@param callback {Function}
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
onUpdateURL(callback) {
|
|
228
|
+
this._removeEventListener();
|
|
229
|
+
|
|
230
|
+
this._popstateHandler = () => {
|
|
231
|
+
// Ignore initial page load popstate event in Chrome
|
|
232
|
+
if (!popstateFired) {
|
|
233
|
+
popstateFired = true;
|
|
234
|
+
|
|
235
|
+
if (this.getURL() === this._previousURL) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
callback(this.getURL());
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
window.addEventListener('popstate', this._popstateHandler);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
Used when using `{{action}}` helper. The url is always appended to the rootURL.
|
|
247
|
+
@private
|
|
248
|
+
@method formatURL
|
|
249
|
+
@param url {String}
|
|
250
|
+
@return formatted url {String}
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
formatURL(url) {
|
|
255
|
+
let {
|
|
256
|
+
rootURL,
|
|
257
|
+
baseURL
|
|
258
|
+
} = this;
|
|
259
|
+
|
|
260
|
+
if (url !== '') {
|
|
261
|
+
// remove trailing slashes if they exists
|
|
262
|
+
rootURL = rootURL.replace(/\/$/, '');
|
|
263
|
+
baseURL = baseURL.replace(/\/$/, '');
|
|
264
|
+
} else if (baseURL[0] === '/' && rootURL[0] === '/') {
|
|
265
|
+
// if baseURL and rootURL both start with a slash
|
|
266
|
+
// ... remove trailing slash from baseURL if it exists
|
|
267
|
+
baseURL = baseURL.replace(/\/$/, '');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return baseURL + rootURL + url;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
Cleans up the HistoryLocation event listener.
|
|
274
|
+
@private
|
|
275
|
+
@method willDestroy
|
|
276
|
+
*/
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
willDestroy() {
|
|
280
|
+
this._removeEventListener();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
_removeEventListener() {
|
|
284
|
+
if (this._popstateHandler) {
|
|
285
|
+
window.removeEventListener('popstate', this._popstateHandler);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
}
|
|
File without changes
|
package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/controller_for.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|