Revert "fix(router): guards restor an incorrect url when used with skipLocationChange"
This reverts commit ad20d7d260
.
This commit is contained in:
parent
909268036b
commit
3e548de99d
|
@ -299,7 +299,6 @@ type NavigationParams = {
|
|||
export class Router {
|
||||
private currentUrlTree: UrlTree;
|
||||
private rawUrlTree: UrlTree;
|
||||
private currentUrlTreeStoredInLocation: UrlTree;
|
||||
|
||||
private navigations: BehaviorSubject<NavigationParams> =
|
||||
new BehaviorSubject<NavigationParams>(null);
|
||||
|
@ -717,7 +716,6 @@ export class Router {
|
|||
let navigationIsSuccessful: boolean;
|
||||
const storedState = this.currentRouterState;
|
||||
const storedUrl = this.currentUrlTree;
|
||||
const storedUrlInLocation = this.currentUrlTreeStoredInLocation;
|
||||
|
||||
routerState$
|
||||
.forEach(({appliedUrl, state, shouldActivate}: any) => {
|
||||
|
@ -728,8 +726,6 @@ export class Router {
|
|||
|
||||
this.currentUrlTree = appliedUrl;
|
||||
this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, rawUrl);
|
||||
this.currentUrlTreeStoredInLocation =
|
||||
shouldPreventPushState ? this.currentUrlTreeStoredInLocation : this.rawUrlTree;
|
||||
|
||||
this.currentRouterState = state;
|
||||
|
||||
|
@ -778,13 +774,14 @@ export class Router {
|
|||
this.currentRouterState = storedState;
|
||||
this.currentUrlTree = storedUrl;
|
||||
this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, rawUrl);
|
||||
this.location.replaceState(this.serializeUrl(storedUrlInLocation));
|
||||
this.location.replaceState(this.serializeUrl(this.rawUrlTree));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private resetUrlToCurrentUrlTree(): void {
|
||||
this.location.replaceState(this.urlSerializer.serialize(this.currentUrlTreeStoredInLocation));
|
||||
const path = this.urlSerializer.serialize(this.rawUrlTree);
|
||||
this.location.replaceState(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1532,27 +1532,6 @@ describe('Integration', () => {
|
|||
expect(location.path()).toEqual('/main/component1');
|
||||
})));
|
||||
|
||||
it('should respect skipLocationChange when guards cancel navigations',
|
||||
fakeAsync(inject([Router, Location], (router: Router, location: Location) => {
|
||||
const fixture = createRoot(router, RootCmp);
|
||||
|
||||
router.resetConfig([
|
||||
{path: 'component1', component: SimpleCmp},
|
||||
{path: 'component2', component: SimpleCmp, canDeactivate: ['alwaysFalse']}
|
||||
]);
|
||||
|
||||
router.navigateByUrl('/component1'); // initial state
|
||||
advance(fixture);
|
||||
|
||||
router.navigateByUrl('/component2', {skipLocationChange: true});
|
||||
advance(fixture);
|
||||
expect(location.path()).toEqual('/component1');
|
||||
|
||||
location.back();
|
||||
advance(fixture);
|
||||
|
||||
expect(location.path()).toEqual('/component1');
|
||||
})));
|
||||
});
|
||||
|
||||
describe('should work when given a class', () => {
|
||||
|
|
Loading…
Reference in New Issue