fix(router): port fixes done on angular current router to the new one
The bugs were fixed on current angular router in the following commits: angular/angular@b2a7fd05cb angular/angular@fa2ce8100b angular/angular@595bcdd1ac Closes #12
This commit is contained in:

committed by
vsavkin

parent
25560ed048
commit
9a67f38728
@ -245,10 +245,10 @@ export class Router {
|
||||
*/
|
||||
parseUrl(url: string): UrlTree { return this.urlSerializer.parse(url); }
|
||||
|
||||
private scheduleNavigation(url: UrlTree, pop: boolean): Promise<boolean> {
|
||||
private scheduleNavigation(url: UrlTree, preventPushState: boolean): Promise<boolean> {
|
||||
const id = ++this.navigationId;
|
||||
this.routerEvents.next(new NavigationStart(id, this.serializeUrl(url)));
|
||||
return Promise.resolve().then((_) => this.runNavigate(url, false, id));
|
||||
return Promise.resolve().then((_) => this.runNavigate(url, preventPushState, id));
|
||||
}
|
||||
|
||||
private setUpLocationChangeListener(): void {
|
||||
@ -257,7 +257,7 @@ export class Router {
|
||||
});
|
||||
}
|
||||
|
||||
private runNavigate(url: UrlTree, pop: boolean, id: number): Promise<boolean> {
|
||||
private runNavigate(url: UrlTree, preventPushState: boolean, id: number): Promise<boolean> {
|
||||
if (id !== this.navigationId) {
|
||||
this.location.go(this.urlSerializer.serialize(this.currentUrlTree));
|
||||
this.routerEvents.next(new NavigationCancel(id, this.serializeUrl(url)));
|
||||
@ -295,7 +295,6 @@ export class Router {
|
||||
})
|
||||
.forEach((shouldActivate) => {
|
||||
if (!shouldActivate || id !== this.navigationId) {
|
||||
this.location.go(this.urlSerializer.serialize(this.currentUrlTree));
|
||||
this.routerEvents.next(new NavigationCancel(id, this.serializeUrl(url)));
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
@ -304,8 +303,13 @@ export class Router {
|
||||
|
||||
this.currentUrlTree = updatedUrl;
|
||||
this.currentRouterState = state;
|
||||
if (!pop) {
|
||||
this.location.go(this.urlSerializer.serialize(updatedUrl));
|
||||
if (!preventPushState) {
|
||||
let path = this.urlSerializer.serialize(updatedUrl);
|
||||
if (this.location.isCurrentPathEqualTo(path)) {
|
||||
this.location.replaceState(path);
|
||||
} else {
|
||||
this.location.go(path);
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(
|
||||
|
Reference in New Issue
Block a user