angular/packages/router/test
Andrew Scott 5883e0536c refactor(router): Remove special logic for hybrid apps (#45240)
This commit removes special (undocumented) logic in the Router code that is
meant to prevent duplicate navigations that result from location syncs in
AngularJS/Angular hybrid applications.

The duplicate navigations can occur when both the Router and the AngularJS sync
code detect a location change via a popstate/hashchange event. When this
happens, the Angular Router schedules a navigation to sync itself with
the browser, but the hybrid listener may also schedule an additional
navigation. There are a few reasons this logic should not be included in
the Router:

* This special logic is not tree shakeable so it introduces a bundle
  size cost for all applications, most of which don't need it.
* There have been many updates to the routing pipeline to tolerate
  duplicate navigations. That is, duplicate navigations can happen and
  routing should still complete successfully.
    * 0e8548f667
    * 9e039ca68b
* The logic is really in the wrong place: The hybrid sync code should be
  the location to handle this. If duplicate navigations are meant to be
  avoided, the hybrid sync code should have handling to _not_ trigger
  duplicate navs.
* This logic _also_ used to exist because the mock location
  helper used for test incorrectly triggered popstate events during
  router navigations. In order to avoid unexpected behavior in tests, this
  logic needed to be added. This incorrect mocking may also have been
  put in place because the upgrade module _would_ see a location change
  event and trigger a duplicate navigation.  The location mock has since been updated to
  match real browser behavior so this is no longer necessary. The
  upgrade module has also been updated to not trigger duplicate
  navigations.  The following commits are related to this:
    * 202a1a5631
    * c6a93001eb

Side note: The `setTimeout` in the location change listener is used to
ensure the ordering of duplicate navigations was consistent. You can see
that the logic being removed here expects the imperative navigation to precede the
popstate/hashchange. With the removal of this code, the `setTimeout` no
longer serves a purpose. However, it has been found that tests can rely
on this behavior (incorrectly) because they expect the navigation to be
complete but in reality, it hasn't even started because the test has not
flushed the timeout. Removing the timeout would be a breaking change as
a result.

PR Close #45240
2022-03-03 09:14:39 -08:00
..
operators refactor(router): take only the first emitted value of every resolver to make it consistent with guards (#44573) 2022-03-01 17:12:37 +00:00
utils build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
apply_redirects.spec.ts refactor(router): move types from config and interfaces to models (#44939) 2022-02-03 12:40:28 -08:00
bootstrap.spec.ts test(common): remove initial navigation since it may redirect to debug.html (#45171) 2022-02-23 09:42:44 -08:00
BUILD.bazel build: switch devmode output to es2015 (#44505) 2022-01-05 23:20:20 +00:00
computed_state_restoration.spec.ts feat(router): Allow symbol keys for Route data and resolve properties (#44519) 2022-01-10 19:43:12 +00:00
config.spec.ts fix(router): Fix type of Route.pathMatch to be more accurate (#45176) 2022-02-24 18:44:07 +00:00
create_router_state.spec.ts fix(router): Fix type of Route.pathMatch to be more accurate (#45176) 2022-02-24 18:44:07 +00:00
create_url_tree.spec.ts fix(router): fix serializeQueryParams logic (#42481) 2021-06-08 10:43:00 -07:00
helpers.ts refactor(router): move types from config and interfaces to models (#44939) 2022-02-03 12:40:28 -08:00
integration.spec.ts refactor(router): Remove special logic for hybrid apps (#45240) 2022-03-03 09:14:39 -08:00
page_title_strategy_spec.ts feat(router): set stricter type for Route.title (#44939) 2022-02-03 12:40:28 -08:00
recognize.spec.ts refactor(router): move types from config and interfaces to models (#44939) 2022-02-03 12:40:28 -08:00
regression_integration.spec.ts test: clean up more entryComponents usages (#44561) 2022-01-06 18:36:22 +00:00
router.spec.ts refactor(router): move types from config and interfaces to models (#44939) 2022-02-03 12:40:28 -08:00
router_link_spec.ts fix(router): null/undefined routerLink should disable navigation (#43087) 2021-08-20 12:51:09 -07:00
router_preloader.spec.ts refactor(router): move types from config and interfaces to models (#44939) 2022-02-03 12:40:28 -08:00
router_scroller.spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
router_state.spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
shared.spec.ts fix(router): fix error when calling ParamMap.get function (#31599) 2020-06-25 11:57:24 -07:00
url_serializer.spec.ts fix(router): fragment can be null (#37336) 2021-03-22 10:02:39 -07:00
url_tree.spec.ts fix(router): Allow question marks in query param values (#31187) 2021-08-06 10:49:37 -07:00