Skip to content

Commit 3bdaae8

Browse files
fix($location): do not get caught in infinite digest in IE9
Closes angular#11439
1 parent 938ea8a commit 3bdaae8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/ng/browser.js

+7
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ function Browser(window, document, $log, $sniffer) {
9292
cacheState();
9393
lastHistoryState = cachedState;
9494

95+
self.forceReloadLocationUpdate = function(url) {
96+
if (reloadLocation) {
97+
reloadLocation = url;
98+
}
99+
};
100+
101+
95102
/**
96103
* @name $browser#url
97104
*

src/ng/location.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ function $LocationProvider() {
894894
$browser.url($location.absUrl(), true);
895895
}
896896

897-
var initializing = true;
897+
var initializing = true, previousOldUrl = null, previousNewUrl = null;
898898

899899
// update $location when $browser url changes
900900
$browser.onUrlChange(function(newUrl, newState) {
@@ -929,6 +929,15 @@ function $LocationProvider() {
929929
$rootScope.$watch(function $locationWatch() {
930930
var oldUrl = trimEmptyHash($browser.url());
931931
var newUrl = trimEmptyHash($location.absUrl());
932+
if ($location.$$html5 && !$sniffer.history) {
933+
if (previousOldUrl === oldUrl && previousNewUrl === newUrl) {
934+
// break out of infinite $digest loops caused by default routes in hashbang mode
935+
$browser.forceReloadLocationUpdate(newUrl);
936+
previousOldUrl = previousNewUrl = null;
937+
return;
938+
}
939+
previousOldUrl = oldUrl, previousNewUrl = newUrl;
940+
}
932941
var oldState = $browser.state();
933942
var currentReplace = $location.$$replace;
934943
var urlOrStateChanged = oldUrl !== newUrl ||

0 commit comments

Comments
 (0)