fix(router): back button does not work in IE11 and Safari
This commit is contained in:
parent
b77a4a40a4
commit
f08060b0b0
|
@ -37,6 +37,8 @@ import {UrlSerializer, UrlTree, createEmptyUrlTree} from './url_tree';
|
||||||
import {forEach, merge, shallowEqual, waitForMap} from './utils/collection';
|
import {forEach, merge, shallowEqual, waitForMap} from './utils/collection';
|
||||||
import {TreeNode} from './utils/tree';
|
import {TreeNode} from './utils/tree';
|
||||||
|
|
||||||
|
declare var Zone: any;
|
||||||
|
|
||||||
export interface NavigationExtras {
|
export interface NavigationExtras {
|
||||||
relativeTo?: ActivatedRoute;
|
relativeTo?: ActivatedRoute;
|
||||||
queryParams?: Params;
|
queryParams?: Params;
|
||||||
|
@ -288,14 +290,16 @@ export class Router {
|
||||||
}
|
}
|
||||||
|
|
||||||
private setUpLocationChangeListener(): void {
|
private setUpLocationChangeListener(): void {
|
||||||
this.locationSubscription = <any>this.location.subscribe((change) => {
|
// Zone.current.wrap is needed because of the issue with RxJS scheduler,
|
||||||
|
// which does not work properly with zone.js in IE and Safari
|
||||||
|
this.locationSubscription = <any>this.location.subscribe(Zone.current.wrap((change: any) => {
|
||||||
const tree = this.urlSerializer.parse(change['url']);
|
const tree = this.urlSerializer.parse(change['url']);
|
||||||
// we fire multiple events for a single URL change
|
// we fire multiple events for a single URL change
|
||||||
// we should navigate only once
|
// we should navigate only once
|
||||||
return this.currentUrlTree.toString() !== tree.toString() ?
|
return this.currentUrlTree.toString() !== tree.toString() ?
|
||||||
this.scheduleNavigation(tree, change['pop']) :
|
this.scheduleNavigation(tree, change['pop']) :
|
||||||
null;
|
null;
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private runNavigate(url: UrlTree, preventPushState: boolean, id: number): Promise<boolean> {
|
private runNavigate(url: UrlTree, preventPushState: boolean, id: number): Promise<boolean> {
|
||||||
|
|
Loading…
Reference in New Issue