diff --git a/packages/router/src/router.ts b/packages/router/src/router.ts index 4057b8e8927..1604191f80a 100644 --- a/packages/router/src/router.ts +++ b/packages/router/src/router.ts @@ -1354,21 +1354,6 @@ export class Router { return Promise.resolve(false); } - // Duplicate navigations may be triggered by attempts to sync AngularJS and - // Angular router states. We have the setTimeout in the location listener to - // ensure the imperative nav is scheduled before the browser nav. - const lastNavigation = this.transitions.value; - const browserNavPrecededByRouterNav = isBrowserTriggeredNavigation(source) && lastNavigation && - !isBrowserTriggeredNavigation(lastNavigation.source); - const navToSameUrl = lastNavigation.rawUrl.toString() === rawUrl.toString(); - const lastNavigationInProgress = lastNavigation.id === this.currentNavigation?.id; - // We consider duplicates as ones that goes to the same URL while the first - // is still processing. - const isDuplicateNav = navToSameUrl && lastNavigationInProgress; - if (browserNavPrecededByRouterNav && isDuplicateNav) { - return Promise.resolve(true); // return value is not used - } - let resolve: any; let reject: any; let promise: Promise; diff --git a/packages/router/test/integration.spec.ts b/packages/router/test/integration.spec.ts index bf9c54b2ecd..a560323200d 100644 --- a/packages/router/test/integration.spec.ts +++ b/packages/router/test/integration.spec.ts @@ -1204,26 +1204,6 @@ describe('Integration', () => { }); }); - it('should ignore the duplicate resulting from a location sync', fakeAsync(() => { - const router = TestBed.inject(Router); - const fixture = createRoot(router, RootCmp); - const location = TestBed.inject(Location) as SpyLocation; - router.resetConfig([{path: 'simple', component: SimpleCmp, canActivate: ['in1Second']}]); - - const recordedEvents: any[] = []; - router.events.forEach(e => onlyNavigationStartAndEnd(e) && recordedEvents.push(e)); - - // setTimeout used so this navigation resolves at the same time as the one that results - // from the location PopStateEvent (see Router#setUpLocationChangeListener). - setTimeout(() => { - router.navigateByUrl('/simple'); - }, 0); - location.simulateUrlPop('/simple'); - tick(1000); - advance(fixture); - expectEvents(recordedEvents, [[NavigationStart, '/simple'], [NavigationEnd, '/simple']]); - })); - it('should reset location if a navigation by location is successful', fakeAsync(() => { const router = TestBed.inject(Router); const location = TestBed.inject(Location) as SpyLocation;