Skip to content

Commit 034b700

Browse files
rwjblueRobbieTheWagner
authored andcommitted
Refactor route anchor jump system (#418)
* avoid making reopen inside `initialize` (it should only be done once **ever** not once per application) * avoid destructuring from `location` when it is not defined (e.g. FastBoot contexts) * ensure that the super result is properly returned (previously we would drop any promises returned from afterModel 😱)
1 parent f3589f9 commit 034b700

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import Route from '@ember/routing/route';
22
import { scheduleOnce } from '@ember/runloop';
33

4-
export function initialize() {
5-
Route.reopen({
6-
afterModel() {
7-
this._super(...arguments);
8-
4+
Route.reopen({
5+
afterModel() {
6+
if (typeof location !== 'undefined') {
97
const { hash } = location;
108
if (hash && hash.length) {
119
scheduleOnce('afterRender', null, () => {
@@ -16,9 +14,13 @@ export function initialize() {
1614
});
1715
}
1816
}
19-
})
20-
}
17+
18+
return this._super(...arguments);
19+
}
20+
});
21+
22+
export function initialize() {}
2123

2224
export default {
23-
initialize
25+
initialize,
2426
};

0 commit comments

Comments
 (0)