fix(router): canDeactivate guards should run from bottom to top
Closes #15657.
This commit is contained in:

committed by
Alex Rickabaugh

parent
eb6fb5f87e
commit
e20cfe1bbc
@ -839,11 +839,10 @@ export class PreActivation {
|
||||
|
||||
// reusing the node
|
||||
if (curr && future._routeConfig === curr._routeConfig) {
|
||||
if (this.shouldRunGuardsAndResolvers(
|
||||
curr, future, future._routeConfig !.runGuardsAndResolvers)) {
|
||||
const shouldRunGuardsAndResolvers = this.shouldRunGuardsAndResolvers(
|
||||
curr, future, future._routeConfig !.runGuardsAndResolvers);
|
||||
if (shouldRunGuardsAndResolvers) {
|
||||
this.canActivateChecks.push(new CanActivate(futurePath));
|
||||
const outlet = context !.outlet !;
|
||||
this.canDeactivateChecks.push(new CanDeactivate(outlet.component, curr));
|
||||
} else {
|
||||
// we need to set the data
|
||||
future.data = curr.data;
|
||||
@ -859,6 +858,11 @@ export class PreActivation {
|
||||
} else {
|
||||
this.traverseChildRoutes(futureNode, currNode, parentContexts, futurePath);
|
||||
}
|
||||
|
||||
if (shouldRunGuardsAndResolvers) {
|
||||
const outlet = context !.outlet !;
|
||||
this.canDeactivateChecks.push(new CanDeactivate(outlet.component, curr));
|
||||
}
|
||||
} else {
|
||||
if (curr) {
|
||||
this.deactivateRouteAndItsChildren(currNode, context);
|
||||
|
Reference in New Issue
Block a user