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,170 +0,0 @@
|
|
|
1
|
-
import { set } from '@ember/-internals/metal';
|
|
2
|
-
import { Object as EmberObject } from '@ember/-internals/runtime';
|
|
3
|
-
import { bind } from '@ember/runloop';
|
|
4
|
-
import { getHash } from './util';
|
|
5
|
-
/**
|
|
6
|
-
@module @ember/routing
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
`HashLocation` implements the location API using the browser's
|
|
11
|
-
hash. At present, it relies on a `hashchange` event existing in the
|
|
12
|
-
browser.
|
|
13
|
-
|
|
14
|
-
Using `HashLocation` results in URLs with a `#` (hash sign) separating the
|
|
15
|
-
server side URL portion of the URL from the portion that is used by Ember.
|
|
16
|
-
|
|
17
|
-
Example:
|
|
18
|
-
|
|
19
|
-
```app/router.js
|
|
20
|
-
Router.map(function() {
|
|
21
|
-
this.route('posts', function() {
|
|
22
|
-
this.route('new');
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
Router.reopen({
|
|
27
|
-
location: 'hash'
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
This will result in a posts.new url of `/#/posts/new`.
|
|
32
|
-
|
|
33
|
-
@class HashLocation
|
|
34
|
-
@extends EmberObject
|
|
35
|
-
@protected
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
export default class HashLocation extends EmberObject {
|
|
39
|
-
constructor() {
|
|
40
|
-
super(...arguments);
|
|
41
|
-
this.implementation = 'hash';
|
|
42
|
-
this.lastSetURL = null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
init() {
|
|
46
|
-
set(this, 'location', this._location || window.location);
|
|
47
|
-
this._hashchangeHandler = undefined;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
@private
|
|
51
|
-
Returns normalized location.hash
|
|
52
|
-
@since 1.5.1
|
|
53
|
-
@method getHash
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
getHash() {
|
|
58
|
-
return getHash(this.location);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
Returns the normalized URL, constructed from `location.hash`.
|
|
62
|
-
e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`.
|
|
63
|
-
By convention, hashed paths must begin with a forward slash, otherwise they
|
|
64
|
-
are not treated as a path so we can distinguish intent.
|
|
65
|
-
@private
|
|
66
|
-
@method getURL
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
getURL() {
|
|
71
|
-
let originalPath = this.getHash().substring(1);
|
|
72
|
-
let outPath = originalPath;
|
|
73
|
-
|
|
74
|
-
if (outPath[0] !== '/') {
|
|
75
|
-
outPath = '/'; // Only add the # if the path isn't empty.
|
|
76
|
-
// We do NOT want `/#` since the ampersand
|
|
77
|
-
// is only included (conventionally) when
|
|
78
|
-
// the location.hash has a value
|
|
79
|
-
|
|
80
|
-
if (originalPath) {
|
|
81
|
-
outPath += `#${originalPath}`;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return outPath;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
Set the `location.hash` and remembers what was set. This prevents
|
|
89
|
-
`onUpdateURL` callbacks from triggering when the hash was set by
|
|
90
|
-
`HashLocation`.
|
|
91
|
-
@private
|
|
92
|
-
@method setURL
|
|
93
|
-
@param path {String}
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
setURL(path) {
|
|
98
|
-
this.location.hash = path;
|
|
99
|
-
set(this, 'lastSetURL', path);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
Uses location.replace to update the url without a page reload
|
|
103
|
-
or history modification.
|
|
104
|
-
@private
|
|
105
|
-
@method replaceURL
|
|
106
|
-
@param path {String}
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
replaceURL(path) {
|
|
111
|
-
this.location.replace(`#${path}`);
|
|
112
|
-
set(this, 'lastSetURL', path);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
Register a callback to be invoked when the hash changes. These
|
|
116
|
-
callbacks will execute when the user presses the back or forward
|
|
117
|
-
button, but not after `setURL` is invoked.
|
|
118
|
-
@private
|
|
119
|
-
@method onUpdateURL
|
|
120
|
-
@param callback {Function}
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
onUpdateURL(callback) {
|
|
125
|
-
this._removeEventListener();
|
|
126
|
-
|
|
127
|
-
this._hashchangeHandler = bind(this, function (_event) {
|
|
128
|
-
let path = this.getURL();
|
|
129
|
-
|
|
130
|
-
if (this.lastSetURL === path) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
set(this, 'lastSetURL', null);
|
|
135
|
-
callback(path);
|
|
136
|
-
});
|
|
137
|
-
window.addEventListener('hashchange', this._hashchangeHandler);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
Given a URL, formats it to be placed into the page as part
|
|
141
|
-
of an element's `href` attribute.
|
|
142
|
-
This is used, for example, when using the {{action}} helper
|
|
143
|
-
to generate a URL based on an event.
|
|
144
|
-
@private
|
|
145
|
-
@method formatURL
|
|
146
|
-
@param url {String}
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
formatURL(url) {
|
|
151
|
-
return `#${url}`;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
Cleans up the HashLocation event listener.
|
|
155
|
-
@private
|
|
156
|
-
@method willDestroy
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
willDestroy() {
|
|
161
|
-
this._removeEventListener();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
_removeEventListener() {
|
|
165
|
-
if (this._hashchangeHandler) {
|
|
166
|
-
window.removeEventListener('hashchange', this._hashchangeHandler);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
}
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import { set } from '@ember/-internals/metal';
|
|
2
|
-
import { Object as EmberObject } from '@ember/-internals/runtime';
|
|
3
|
-
import { getHash } from './util';
|
|
4
|
-
/**
|
|
5
|
-
@module @ember/routing
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
let popstateFired = false;
|
|
9
|
-
|
|
10
|
-
function _uuid() {
|
|
11
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
12
|
-
let r, v;
|
|
13
|
-
r = Math.random() * 16 | 0;
|
|
14
|
-
v = c === 'x' ? r : r & 3 | 8;
|
|
15
|
-
return v.toString(16);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
HistoryLocation implements the location API using the browser's
|
|
20
|
-
history.pushState API.
|
|
21
|
-
|
|
22
|
-
Using `HistoryLocation` results in URLs that are indistinguishable from a
|
|
23
|
-
standard URL. This relies upon the browser's `history` API.
|
|
24
|
-
|
|
25
|
-
Example:
|
|
26
|
-
|
|
27
|
-
```app/router.js
|
|
28
|
-
Router.map(function() {
|
|
29
|
-
this.route('posts', function() {
|
|
30
|
-
this.route('new');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
Router.reopen({
|
|
35
|
-
location: 'history'
|
|
36
|
-
});
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
This will result in a posts.new url of `/posts/new`.
|
|
40
|
-
|
|
41
|
-
Keep in mind that your server must serve the Ember app at all the routes you
|
|
42
|
-
define.
|
|
43
|
-
|
|
44
|
-
Using `HistoryLocation` will also result in location states being recorded by
|
|
45
|
-
the browser `history` API with the following schema:
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
window.history.state -> { path: '/', uuid: '3552e730-b4a6-46bd-b8bf-d8c3c1a97e0a' }
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
This allows each in-app location state to be tracked uniquely across history
|
|
52
|
-
state changes via the `uuid` field.
|
|
53
|
-
|
|
54
|
-
@class HistoryLocation
|
|
55
|
-
@extends EmberObject
|
|
56
|
-
@protected
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export default class HistoryLocation extends EmberObject {
|
|
61
|
-
constructor() {
|
|
62
|
-
super(...arguments);
|
|
63
|
-
this.implementation = 'history';
|
|
64
|
-
/**
|
|
65
|
-
Will be pre-pended to path upon state change
|
|
66
|
-
@property rootURL
|
|
67
|
-
@default '/'
|
|
68
|
-
@private
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
this.rootURL = '/';
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
@private
|
|
75
|
-
Returns normalized location.hash
|
|
76
|
-
@method getHash
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
getHash() {
|
|
81
|
-
return getHash(this.location);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
init() {
|
|
85
|
-
var _a;
|
|
86
|
-
|
|
87
|
-
this._super(...arguments);
|
|
88
|
-
|
|
89
|
-
let base = document.querySelector('base');
|
|
90
|
-
let baseURL = '';
|
|
91
|
-
|
|
92
|
-
if (base !== null && base.hasAttribute('href')) {
|
|
93
|
-
baseURL = (_a = base.getAttribute('href')) !== null && _a !== void 0 ? _a : '';
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
set(this, 'baseURL', baseURL);
|
|
97
|
-
set(this, 'location', this.location || window.location);
|
|
98
|
-
this._popstateHandler = undefined;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
Used to set state on first call to setURL
|
|
102
|
-
@private
|
|
103
|
-
@method initState
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
initState() {
|
|
108
|
-
let history = this.history || window.history;
|
|
109
|
-
set(this, 'history', history);
|
|
110
|
-
let {
|
|
111
|
-
state
|
|
112
|
-
} = history;
|
|
113
|
-
let path = this.formatURL(this.getURL());
|
|
114
|
-
|
|
115
|
-
if (state && state.path === path) {
|
|
116
|
-
// preserve existing state
|
|
117
|
-
// used for webkit workaround, since there will be no initial popstate event
|
|
118
|
-
this._previousURL = this.getURL();
|
|
119
|
-
} else {
|
|
120
|
-
this.replaceState(path);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
Returns the current `location.pathname` without `rootURL` or `baseURL`
|
|
125
|
-
@private
|
|
126
|
-
@method getURL
|
|
127
|
-
@return url {String}
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
getURL() {
|
|
132
|
-
let {
|
|
133
|
-
location,
|
|
134
|
-
rootURL,
|
|
135
|
-
baseURL
|
|
136
|
-
} = this;
|
|
137
|
-
let path = location.pathname; // remove trailing slashes if they exists
|
|
138
|
-
|
|
139
|
-
rootURL = rootURL.replace(/\/$/, '');
|
|
140
|
-
baseURL = baseURL.replace(/\/$/, ''); // remove baseURL and rootURL from start of path
|
|
141
|
-
|
|
142
|
-
let url = path.replace(new RegExp(`^${baseURL}(?=/|$)`), '').replace(new RegExp(`^${rootURL}(?=/|$)`), '').replace(/\/\//g, '/'); // remove extra slashes
|
|
143
|
-
|
|
144
|
-
let search = location.search || '';
|
|
145
|
-
url += search + this.getHash();
|
|
146
|
-
return url;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
Uses `history.pushState` to update the url without a page reload.
|
|
150
|
-
@private
|
|
151
|
-
@method setURL
|
|
152
|
-
@param path {String}
|
|
153
|
-
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
setURL(path) {
|
|
157
|
-
let {
|
|
158
|
-
state
|
|
159
|
-
} = this.history;
|
|
160
|
-
path = this.formatURL(path);
|
|
161
|
-
|
|
162
|
-
if (!state || state.path !== path) {
|
|
163
|
-
this.pushState(path);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
Uses `history.replaceState` to update the url without a page reload
|
|
168
|
-
or history modification.
|
|
169
|
-
@private
|
|
170
|
-
@method replaceURL
|
|
171
|
-
@param path {String}
|
|
172
|
-
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
replaceURL(path) {
|
|
176
|
-
let {
|
|
177
|
-
state
|
|
178
|
-
} = this.history;
|
|
179
|
-
path = this.formatURL(path);
|
|
180
|
-
|
|
181
|
-
if (!state || state.path !== path) {
|
|
182
|
-
this.replaceState(path);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
Pushes a new state.
|
|
187
|
-
@private
|
|
188
|
-
@method pushState
|
|
189
|
-
@param path {String}
|
|
190
|
-
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
pushState(path) {
|
|
194
|
-
let state = {
|
|
195
|
-
path,
|
|
196
|
-
uuid: _uuid()
|
|
197
|
-
};
|
|
198
|
-
this.history.pushState(state, null, path); // used for webkit workaround
|
|
199
|
-
|
|
200
|
-
this._previousURL = this.getURL();
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
Replaces the current state.
|
|
204
|
-
@private
|
|
205
|
-
@method replaceState
|
|
206
|
-
@param path {String}
|
|
207
|
-
*/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
replaceState(path) {
|
|
211
|
-
let state = {
|
|
212
|
-
path,
|
|
213
|
-
uuid: _uuid()
|
|
214
|
-
};
|
|
215
|
-
this.history.replaceState(state, null, path); // used for webkit workaround
|
|
216
|
-
|
|
217
|
-
this._previousURL = this.getURL();
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
Register a callback to be invoked whenever the browser
|
|
221
|
-
history changes, including using forward and back buttons.
|
|
222
|
-
@private
|
|
223
|
-
@method onUpdateURL
|
|
224
|
-
@param callback {Function}
|
|
225
|
-
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
onUpdateURL(callback) {
|
|
229
|
-
this._removeEventListener();
|
|
230
|
-
|
|
231
|
-
this._popstateHandler = () => {
|
|
232
|
-
// Ignore initial page load popstate event in Chrome
|
|
233
|
-
if (!popstateFired) {
|
|
234
|
-
popstateFired = true;
|
|
235
|
-
|
|
236
|
-
if (this.getURL() === this._previousURL) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
callback(this.getURL());
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
window.addEventListener('popstate', this._popstateHandler);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
Used when using `{{action}}` helper. The url is always appended to the rootURL.
|
|
248
|
-
@private
|
|
249
|
-
@method formatURL
|
|
250
|
-
@param url {String}
|
|
251
|
-
@return formatted url {String}
|
|
252
|
-
*/
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
formatURL(url) {
|
|
256
|
-
let {
|
|
257
|
-
rootURL,
|
|
258
|
-
baseURL
|
|
259
|
-
} = this;
|
|
260
|
-
|
|
261
|
-
if (url !== '') {
|
|
262
|
-
// remove trailing slashes if they exists
|
|
263
|
-
rootURL = rootURL.replace(/\/$/, '');
|
|
264
|
-
baseURL = baseURL.replace(/\/$/, '');
|
|
265
|
-
} else if (baseURL[0] === '/' && rootURL[0] === '/') {
|
|
266
|
-
// if baseURL and rootURL both start with a slash
|
|
267
|
-
// ... remove trailing slash from baseURL if it exists
|
|
268
|
-
baseURL = baseURL.replace(/\/$/, '');
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return baseURL + rootURL + url;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
Cleans up the HistoryLocation event listener.
|
|
275
|
-
@private
|
|
276
|
-
@method willDestroy
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
willDestroy() {
|
|
281
|
-
this._removeEventListener();
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
_removeEventListener() {
|
|
285
|
-
if (this._popstateHandler) {
|
|
286
|
-
window.removeEventListener('popstate', this._popstateHandler);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { set } from '@ember/-internals/metal';
|
|
2
|
-
import { Object as EmberObject } from '@ember/-internals/runtime';
|
|
3
|
-
import { assert } from '@ember/debug';
|
|
4
|
-
/**
|
|
5
|
-
@module @ember/routing
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
NoneLocation does not interact with the browser. It is useful for
|
|
10
|
-
testing, or when you need to manage state with your Router, but temporarily
|
|
11
|
-
don't want it to muck with the URL (for example when you embed your
|
|
12
|
-
application in a larger page).
|
|
13
|
-
|
|
14
|
-
Using `NoneLocation` causes Ember to not store the applications URL state
|
|
15
|
-
in the actual URL. This is generally used for testing purposes, and is one
|
|
16
|
-
of the changes made when calling `App.setupForTesting()`.
|
|
17
|
-
|
|
18
|
-
@class NoneLocation
|
|
19
|
-
@extends EmberObject
|
|
20
|
-
@protected
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export default class NoneLocation extends EmberObject {
|
|
24
|
-
constructor() {
|
|
25
|
-
super(...arguments);
|
|
26
|
-
this.implementation = 'none';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
initState() {
|
|
30
|
-
this._super(...arguments);
|
|
31
|
-
|
|
32
|
-
let {
|
|
33
|
-
rootURL
|
|
34
|
-
} = this; // This assert doesn't have anything to do with state initialization,
|
|
35
|
-
// but we're hijacking this method since it's called after the route has
|
|
36
|
-
// set the rootURL property on its Location instance.
|
|
37
|
-
|
|
38
|
-
assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/');
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
Returns the current path without `rootURL`.
|
|
42
|
-
@private
|
|
43
|
-
@method getURL
|
|
44
|
-
@return {String} path
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
getURL() {
|
|
49
|
-
let {
|
|
50
|
-
path,
|
|
51
|
-
rootURL
|
|
52
|
-
} = this; // remove trailing slashes if they exists
|
|
53
|
-
|
|
54
|
-
rootURL = rootURL.replace(/\/$/, ''); // remove rootURL from url
|
|
55
|
-
|
|
56
|
-
return path.replace(new RegExp(`^${rootURL}(?=/|$)`), '');
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
Set the path and remembers what was set. Using this method
|
|
60
|
-
to change the path will not invoke the `updateURL` callback.
|
|
61
|
-
@private
|
|
62
|
-
@method setURL
|
|
63
|
-
@param path {String}
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
setURL(path) {
|
|
68
|
-
set(this, 'path', path);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
Register a callback to be invoked when the path changes. These
|
|
72
|
-
callbacks will execute when the user presses the back or forward
|
|
73
|
-
button, but not after `setURL` is invoked.
|
|
74
|
-
@private
|
|
75
|
-
@method onUpdateURL
|
|
76
|
-
@param callback {Function}
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
onUpdateURL(callback) {
|
|
81
|
-
this.updateCallback = callback;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
Sets the path and calls the `updateURL` callback.
|
|
85
|
-
@private
|
|
86
|
-
@method handleURL
|
|
87
|
-
@param url {String}
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
handleURL(url) {
|
|
92
|
-
set(this, 'path', url);
|
|
93
|
-
this.updateCallback(url);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
Given a URL, formats it to be placed into the page as part
|
|
97
|
-
of an element's `href` attribute.
|
|
98
|
-
This is used, for example, when using the {{action}} helper
|
|
99
|
-
to generate a URL based on an event.
|
|
100
|
-
@private
|
|
101
|
-
@method formatURL
|
|
102
|
-
@param url {String}
|
|
103
|
-
@return {String} url
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
formatURL(url) {
|
|
108
|
-
let {
|
|
109
|
-
rootURL
|
|
110
|
-
} = this;
|
|
111
|
-
|
|
112
|
-
if (url !== '') {
|
|
113
|
-
// remove trailing slashes if they exists
|
|
114
|
-
rootURL = rootURL.replace(/\/$/, '');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return rootURL + url;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
NoneLocation.reopen({
|
|
122
|
-
path: '',
|
|
123
|
-
rootURL: '/'
|
|
124
|
-
});
|