Skip to content

Commit ce51ea9

Browse files
JiaLiPassionalxhub
authored andcommitted
fix(core): fix #20582, don't need to wrap zone in location change listener (#22007)
PR Close #22007
1 parent d38e088 commit ce51ea9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎packages/router/src/router.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import {UrlSerializer, UrlTree, containsTree, createEmptyUrlTree} from './url_tr
3434
import {forEach} from './utils/collection';
3535
import {TreeNode, nodeChildrenAsMap} from './utils/tree';
3636

37-
declare let Zone: any;
38-
3937
/**
4038
* @whatItDoes Represents the extra options used during navigation.
4139
*
@@ -306,14 +304,15 @@ export class Router {
306304
* Sets up the location change listener.
307305
*/
308306
setUpLocationChangeListener(): void {
309-
// Zone.current.wrap is needed because of the issue with RxJS scheduler,
310-
// which does not work properly with zone.js in IE and Safari
307+
// Don't need to use Zone.wrap any more, because zone.js
308+
// already patch onPopState, so location change callback will
309+
// run into ngZone
311310
if (!this.locationSubscription) {
312-
this.locationSubscription = <any>this.location.subscribe(Zone.current.wrap((change: any) => {
311+
this.locationSubscription = <any>this.location.subscribe((change: any) => {
313312
const rawUrlTree = this.urlSerializer.parse(change['url']);
314313
const source: NavigationSource = change['type'] === 'popstate' ? 'popstate' : 'hashchange';
315314
setTimeout(() => { this.scheduleNavigation(rawUrlTree, source, {replaceUrl: true}); }, 0);
316-
}));
315+
});
317316
}
318317
}
319318

0 commit comments

Comments
 (0)