Skip to content

Commit

Permalink
fix($location): re-assign location after BFCache back
Browse files Browse the repository at this point in the history
In the Android browser, the BFCache maintains
the state of JavaScript applications even when
navigating to another app, so that going
forward and back, to and from an application
is very fast.

Unfortunately, this can have undesired side
effects. In this instance, the location
variable was holding a reference to a stale
window.location, and was throwing errors
when going back to an Angular app after
browsing to another site.

This fix makes sure that location.url()
includes a check to make sure that location
is referencing the current window.location.

Closes angular#4044
  • Loading branch information
jeffbcross authored and jamesdaily committed Jan 27, 2014
1 parent 9b741ac commit 8d931ac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ function Browser(window, document, $log, $sniffer) {
* @param {boolean=} replace Should new url replace current history record ?
*/
self.url = function(url, replace) {
// Android Browser BFCache causes location reference to become stale.
if (location !== window.location) location = window.location;

// setter
if (url) {
if (lastBrowserUrl == url) return;
Expand Down

0 comments on commit 8d931ac

Please sign in to comment.