Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 488f746

Browse files
committed
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
1 parent b64519f commit 488f746

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/ng/location.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ function $LocationProvider() {
883883
$browser.url($location.absUrl(), true);
884884
}
885885

886-
var initializing = true;
886+
var initializing = true, skipLocationWatch = false;
887887

888888
// update $location when $browser url changes
889889
$browser.onUrlChange(function(newUrl, newState) {
@@ -916,6 +916,11 @@ function $LocationProvider() {
916916

917917
// update browser
918918
$rootScope.$watch(function $locationWatch() {
919+
if (skipLocationWatch && !$location.$$replace) {
920+
//prevent infinite $digest errors in hashbang mode
921+
skipLocationWatch = false;
922+
return;
923+
}
919924
var oldUrl = trimEmptyHash($browser.url());
920925
var newUrl = trimEmptyHash($location.absUrl());
921926
var oldState = $browser.state();
@@ -943,7 +948,12 @@ function $LocationProvider() {
943948
setBrowserUrlWithFallback(newUrl, currentReplace,
944949
oldState === $location.$$state ? null : $location.$$state);
945950
}
951+
var oldLocationAbsUrl = $location.absUrl();
946952
afterLocationChange(oldUrl, oldState);
953+
if (oldLocationAbsUrl !== $location.absUrl() &&
954+
trimEmptyHash($location.absUrl()) !== trimEmptyHash($browser.url())) {
955+
skipLocationWatch = true;
956+
}
947957
}
948958
});
949959
}

0 commit comments

Comments
 (0)