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

Commit 97abb12

Browse files
Pavel VasekIgorMinar
Pavel Vasek
authored andcommitted
fix($location): prevent infinite digest error due to IE bug
If an app uses HTML5 mode and we open an html5 url on IE8 or 9 which don't support location href, we use location.replace to reload the page with the hashbang equivalent of the url but this fails with infinite digest. This is because location.replace doesn't update location.href synchronously on IE8 and 9. Closes #2802, #3305, #1417
1 parent d26bffb commit 97abb12

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/ng/browser.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ function Browser(window, document, $log, $sniffer) {
124124
//////////////////////////////////////////////////////////////
125125

126126
var lastBrowserUrl = location.href,
127-
baseElement = document.find('base');
127+
baseElement = document.find('base'),
128+
replacedUrl = null;
128129

129130
/**
130131
* @name ng.$browser#url
@@ -159,14 +160,21 @@ function Browser(window, document, $log, $sniffer) {
159160
baseElement.attr('href', baseElement.attr('href'));
160161
}
161162
} else {
162-
if (replace) location.replace(url);
163-
else location.href = url;
163+
if (replace) {
164+
location.replace(url);
165+
replacedUrl = url;
166+
} else {
167+
location.href = url;
168+
replacedUrl = null;
169+
}
164170
}
165171
return self;
166172
// getter
167173
} else {
168-
// the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172
169-
return location.href.replace(/%27/g,"'");
174+
// - the replacedUrl is a workaround for an IE8-9 issue with location.replace method that doesn't update
175+
// location.href synchronously
176+
// - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172
177+
return replacedUrl || location.href.replace(/%27/g,"'");
170178
}
171179
};
172180

0 commit comments

Comments
 (0)