aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Cross2013-09-30 12:00:50 -0700
committerJeff Cross2013-09-30 13:02:40 -0700
commit2ebf93163027abc55ba27f673be3b8dc1281c068 (patch)
treee9b5a631096d0411779ec6362b8f32e3b18f9caf
parent8727fce31290de3067639f7ac4f16cfb2141ae18 (diff)
downloadangular.js-2ebf93163027abc55ba27f673be3b8dc1281c068.tar.bz2
fix($location): re-assign location after BFCache back
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 #4044
-rw-r--r--src/ng/browser.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ng/browser.js b/src/ng/browser.js
index 0aa59f66..768720e7 100644
--- a/src/ng/browser.js
+++ b/src/ng/browser.js
@@ -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;