mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
9e039ca68b
With the merging of #41730, our tests now more closely emulate real browser behavior. This means that we can make changes to the `Router` which depend on actual browser behavior rather than incorrectly mocked test behavior. This change updates the logic in the `Router` to only trigger navigations on `popstate` events. Since our `SpyLocation` now triggers the `popstate` event correctly on `simulateHashChange`, `back`, `forward`, and `simulatePopState`, we are able to rely on this being true for all of these navigations in tests when using `SpyLocation` (the default for `RouterTestingModule`). In addition, this behavior relies on documented browser behavior: The `popstate` event happens due to browser transitions as a result of user triggered "back" button or otherwise. https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent In addition, this change chooses `popstate` over `hashchange` because it is the event that is already being used for navigations since the documented behavior of browsers is that `popstate` happens before `hashchange`. fixes #41782 PR Close #43328
Angular
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in Angular documentation.
License: MIT