From 488f74626d3b08f0155852d1d27ea231e090dc3b Mon Sep 17 00:00:00 2001 From: hamfastgamgee Date: Tue, 14 Apr 2015 10:39:00 -0500 Subject: [PATCH 1/2] fix($location): prevent infinite $digest from no trailing slash in IE9 fix($location): prevent infinite $digest from no trailing slash in IE9 This fix prevents IE9 from throwing an infinite $digest error when the user accesses the base URL of the site without a trailing slash. Suppose you owned http://www.mysite.com/app and had an Angular app hosted in a subdirectory "app". If an IE9 user accessed http://www.mysite.com/app infinite $digest errors would be thrown on the console, but the app itself would eventually resolve properly and work fine. Now the infinite $digest errors will not be thrown. Closes #11439 --- src/ng/location.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ng/location.js b/src/ng/location.js index ffee4cd4820f..e33d71612899 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -883,7 +883,7 @@ function $LocationProvider() { $browser.url($location.absUrl(), true); } - var initializing = true; + var initializing = true, skipLocationWatch = false; // update $location when $browser url changes $browser.onUrlChange(function(newUrl, newState) { @@ -916,6 +916,11 @@ function $LocationProvider() { // update browser $rootScope.$watch(function $locationWatch() { + if (skipLocationWatch && !$location.$$replace) { + //prevent infinite $digest errors in hashbang mode + skipLocationWatch = false; + return; + } var oldUrl = trimEmptyHash($browser.url()); var newUrl = trimEmptyHash($location.absUrl()); var oldState = $browser.state(); @@ -943,7 +948,12 @@ function $LocationProvider() { setBrowserUrlWithFallback(newUrl, currentReplace, oldState === $location.$$state ? null : $location.$$state); } + var oldLocationAbsUrl = $location.absUrl(); afterLocationChange(oldUrl, oldState); + if (oldLocationAbsUrl !== $location.absUrl() && + trimEmptyHash($location.absUrl()) !== trimEmptyHash($browser.url())) { + skipLocationWatch = true; + } } }); } From f652b672dd3cf5200eef330c429c067c78e59422 Mon Sep 17 00:00:00 2001 From: hamfastgamgee Date: Tue, 14 Apr 2015 13:29:25 -0500 Subject: [PATCH 2/2] Revert "fix($location): prevent infinite $digest from no trailing slash in IE9" This reverts commit 488f74626d3b08f0155852d1d27ea231e090dc3b. --- src/ng/location.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/ng/location.js b/src/ng/location.js index e33d71612899..ffee4cd4820f 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -883,7 +883,7 @@ function $LocationProvider() { $browser.url($location.absUrl(), true); } - var initializing = true, skipLocationWatch = false; + var initializing = true; // update $location when $browser url changes $browser.onUrlChange(function(newUrl, newState) { @@ -916,11 +916,6 @@ function $LocationProvider() { // update browser $rootScope.$watch(function $locationWatch() { - if (skipLocationWatch && !$location.$$replace) { - //prevent infinite $digest errors in hashbang mode - skipLocationWatch = false; - return; - } var oldUrl = trimEmptyHash($browser.url()); var newUrl = trimEmptyHash($location.absUrl()); var oldState = $browser.state(); @@ -948,12 +943,7 @@ function $LocationProvider() { setBrowserUrlWithFallback(newUrl, currentReplace, oldState === $location.$$state ? null : $location.$$state); } - var oldLocationAbsUrl = $location.absUrl(); afterLocationChange(oldUrl, oldState); - if (oldLocationAbsUrl !== $location.absUrl() && - trimEmptyHash($location.absUrl()) !== trimEmptyHash($browser.url())) { - skipLocationWatch = true; - } } }); }