mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(router): clear pending navigation task in a microtask (#49619)
This commit updates the logic in the Router that keep track of the initial navigation from being a synchronous to a microtask (Promise.resolve) to allow redirects during the initial navigation. PR Close #49619
This commit is contained in:
committed by
Andrew Scott
parent
c024574f46
commit
6bcdb68e69
@@ -742,7 +742,11 @@ export class Router {
|
||||
|
||||
// Indicate that the navigation is happening.
|
||||
const taskId = this.pendingTasks.add();
|
||||
afterNextNavigation(this, () => this.pendingTasks.remove(taskId));
|
||||
afterNextNavigation(this, () => {
|
||||
// Remove pending task in a microtask to allow for cancelled
|
||||
// initial navigations and redirects within the same task.
|
||||
Promise.resolve().then(() => this.pendingTasks.remove(taskId));
|
||||
});
|
||||
|
||||
this.navigationTransitions.handleNavigationRequest({
|
||||
targetPageId,
|
||||
|
||||
Reference in New Issue
Block a user