From ce51ea93a15241d2708f3bf749d268481106ea0a Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Sat, 3 Feb 2018 09:47:30 +0900 Subject: [PATCH] fix(core): fix #20582, don't need to wrap zone in location change listener (#22007) PR Close #22007 --- packages/router/src/router.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/router/src/router.ts b/packages/router/src/router.ts index 4c1f278c3c..b471ae559a 100644 --- a/packages/router/src/router.ts +++ b/packages/router/src/router.ts @@ -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. * @@ -306,14 +304,15 @@ 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 = this.location.subscribe(Zone.current.wrap((change: any) => { + this.locationSubscription = this.location.subscribe((change: any) => { const rawUrlTree = this.urlSerializer.parse(change['url']); const source: NavigationSource = change['type'] === 'popstate' ? 'popstate' : 'hashchange'; setTimeout(() => { this.scheduleNavigation(rawUrlTree, source, {replaceUrl: true}); }, 0); - })); + }); } }