This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($browser): don’t use history api when only the hash changes #9406
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IE10/11 have the following problem: When changing the url hash via `history.pushState()` and then reverting the hash via direct changes to `location.href` (or via a link) does not fire a `hashchange` nor `popstate` event. This commit changes the default behavior as follows: Uses `location.href`/`location.replace` if the new url differs from the previous url only in the hash fragment or the browser does not support history API. Use `history.pushState`/ `history.replaceState` otherwise. Fixes angular#9143
@IgorMinar Could you review this? |
You can use the last plunker in the example and SauceLabs to verify the bug and also that my commit fixes it (by including a locally built angular version). |
Fixes #8869 as well. |
This also fixes the case where you modify by hand the hash in the browser's url field. |
@@ -445,6 +445,17 @@ describe('browser', function() { | |||
expect(locationReplace).not.toHaveBeenCalled(); | |||
}); | |||
|
|||
it('should set location.href when the url only changed in the hash fragment', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather:
should set location.href and not use pushState when ... to please IE10/11
tbosch
added a commit
that referenced
this pull request
Oct 3, 2014
IE10/11 have the following problem: When changing the url hash via `history.pushState()` and then reverting the hash via direct changes to `location.href` (or via a link) does not fire a `hashchange` nor `popstate` event. This commit changes the default behavior as follows: Uses `location.href`/`location.replace` if the new url differs from the previous url only in the hash fragment or the browser does not support history API. Use `history.pushState`/ `history.replaceState` otherwise. Fixes #9143 Closes #9406
tbosch
added a commit
to tbosch/angular.js
that referenced
this pull request
Oct 7, 2014
IE10/11 have the following problem: When changing the url hash via `history.pushState()` and then reverting the hash via direct changes to `location.href` (or via a link) does not fire a `hashchange` nor `popstate` event. This commit changes the default behavior as follows: Uses `location.href`/`location.replace` if the new url differs from the previous url only in the hash fragment or the browser does not support history API. Use `history.pushState`/ `history.replaceState` otherwise. Fixes angular#9143 Closes angular#9406
tbosch
added a commit
that referenced
this pull request
Oct 7, 2014
IE10/11 have the following problem: When changing the url hash via `history.pushState()` and then reverting the hash via direct changes to `location.href` (or via a link) does not fire a `hashchange` nor `popstate` event. This commit changes the default behavior as follows: Uses `location.href`/`location.replace` if the new url differs from the previous url only in the hash fragment or the browser does not support history API. Use `history.pushState`/ `history.replaceState` otherwise. Fixes #9143 Closes #9406
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
IE10/11 have the following problem: When changing the url hash
via
history.pushState()
and then reverting the hash via directchanges to
location.href
(or via a link) does not fire ahashchange
norpopstate
event.This commit changes the default behavior as follows:
Uses
location.href
/location.replace
if the new url differs fromthe previous url only in the hash fragment or the browser
does not support history API.
Use
history.pushState
/history.replaceState
otherwise.Fixes #9143