From 2ebf93163027abc55ba27f673be3b8dc1281c068 Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Mon, 30 Sep 2013 12:00:50 -0700 Subject: [PATCH] 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 --- src/ng/browser.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ng/browser.js b/src/ng/browser.js index 0aa59f665cfd..768720e76a89 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;