You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
fix($location): correctly handle external URL change during $digest
Previously, when the URL was changed directly (e.g. via `location.href`) during
a `$digest` (e.g. via `scope.$evalAsync()` or `promise.then()`) the change was
not handled correctly, unless a `popstate` or `hashchange` event was fired
synchronously.
This wasn't an issue in most browsers, where the `popstate` event was fired
synchronously. In IE11 though, the `popstate` event is not fired at all for
hash-only changes ([known bug][1]) and the `hashchange` event is fired
asynchronously (which is too late).
This commit fixes it by keeping track of `$location` setter methods being called
and only processing a URL change if it originated from such a call. If there is
a URL difference but no setter method has been called, this means that the
browser URL has been updated directly and the change hasn't yet been propagated
to `$location` (e.g. due to no synchronous `popstate` event). In that case, the
change will be propagated later by the (asynchronous) `hashchange` event.
[1]: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/3740423/Fixes#15556
0 commit comments