Skip to content

Commit

Permalink
fix(core): fix angular#20582, don't need to wrap zone in location cha…
Browse files Browse the repository at this point in the history
…nge listener (angular#20640)

PR Close angular#20640
  • Loading branch information
JiaLiPassion authored and alxhub committed Feb 5, 2018
1 parent 3aa7e02 commit f791e9f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import {UrlSerializer, UrlTree, containsTree, createEmptyUrlTree} from './url_tr
import {forEach} from './utils/collection';
import {TreeNode, nodeChildrenAsMap} from './utils/tree';

declare let Zone: any;

/**
* @whatItDoes Represents the extra options used during navigation.
*
Expand Down Expand Up @@ -306,18 +304,19 @@ export class Router {
* Sets up the location change listener.
*/
setUpLocationChangeListener(): void {
// Zone.current.wrap is needed because of the issue with RxJS scheduler,
// which does not work properly with zone.js in IE and Safari
// Don't need to use Zone.wrap any more, because zone.js
// already patch onPopState, so location change callback will
// run into ngZone
if (!this.locationSubscription) {
this.locationSubscription = <any>this.location.subscribe(Zone.current.wrap((change: any) => {
this.locationSubscription = <any>this.location.subscribe((change: any) => {
const rawUrlTree = this.urlSerializer.parse(change['url']);
const source: NavigationTrigger = change['type'] === 'popstate' ? 'popstate' : 'hashchange';
const state = change.state && change.state.navigationId ?
{navigationId: change.state.navigationId} :
null;
setTimeout(
() => { this.scheduleNavigation(rawUrlTree, source, state, {replaceUrl: true}); }, 0);
}));
});
}
}

Expand Down

0 comments on commit f791e9f

Please sign in to comment.