-
Notifications
You must be signed in to change notification settings - Fork 27.4k
infinite $digest when using history api #6976
Comments
This problem present itself also on Windows Phone running IE9. |
@jeffbcross this looks similar to the encoding issue we discussed today (#5019) |
@jeffbcross can you please take a look |
@IgorMinar yep |
Reproduction as test: it('should not cause infinite digest when replacing outside of Angular', function() {
module(function($windowProvider, $locationProvider, $browserProvider) {
// $locationProvider.html5Mode(true);
$browserProvider.$get = function($document, $window) {
var sniffer = {history: true, hashchange: true}
var logs = {log:[], warn:[], info:[], error:[]};
var fakeLog = {log: function() { logs.log.push(slice.call(arguments)); },
warn: function() { logs.warn.push(slice.call(arguments)); },
info: function() { logs.info.push(slice.call(arguments)); },
error: function() { logs.error.push(slice.call(arguments)); }};
var b = new Browser($window, $document, fakeLog, sniffer);
b.pollFns = [];
return b;
}
});
inject(function($rootScope, $location){
window.history.replaceState(null, '', '/hello');
expect(function() {
$rootScope.$digest();
}).not.toThrow();
});
}); |
The problem is caused because Angular isn't synchronously notified of changes to the browser's url, and trusts its cached version of the url inside To verify that this is true, add this line in the provided test just after the This issue could be easily fixed with one line inside of |
My fix from the previous comment fixes the infinite digest error, but doesn't actually retain the new path. |
…er.url() getter Related to angular#6976
…de of Angular $browser keeps an internal representation of the browser's url, and although $browser.url() would return the client's real current url, the $location service that was comparing that url with $location's representation had no way of knowing when the url had been changed outside of Angular. This commit makes browser and location a little bit smarter by setting a flag inside of $browser when it detects that a url changed outside of Angular, allowing $location to parse the new url and update its own internal representation of the url (and react appropriately). Fixes angular#6976
…de of Angular $browser keeps an internal representation of the browser's url, and although $browser.url() would return the client's real current url, the $location service that was comparing that url with $location's representation had no way of knowing when the url had been changed outside of Angular. This commit makes browser and location a little bit smarter by setting a flag inside of $browser when it detects that a url changed outside of Angular, allowing $location to parse the new url and update its own internal representation of the url (and react appropriately). Fixes angular#6976
…de of Angular $browser keeps an internal representation of the browser's url, and although $browser.url() would return the client's real current url, the $location service that was comparing that url with $location's representation had no way of knowing when the url had been changed outside of Angular. This commit makes browser and location a little bit smarter by setting a flag inside of $browser when it detects that a url changed outside of Angular, allowing $location to parse the new url and update its own internal representation of the url (and react appropriately). Fixes angular#6976
Adds caching for url changes after a reload happens Removes unnecessary caching from $browser, as IE-IE9 all allow to change `location.href` synchronously, i.e. after changing it (via property write or `location.replace) it can be read out immediately with the up to date value. There was a wrong assumption in the previous version of this code introduced by dca2317 and d707114. Adds more tests for angular#6976 Fixes angular#9235
Adds caching for url changes while a reload is happening, as browsers do not allow to read out the new location the browser is navigating to. Removes unnecessary caching from $browser, as IE7-IE9 all have the new hash value in `location.href` after changing it. There was a wrong assumption in the previous version of this code introduced by dca2317 and d707114. Adds more tests for angular#6976 Fixes angular#9235
Adds caching for url changes while a reload is happening, as browsers do not allow to read out the new location the browser is navigating to. Removes unnecessary caching from $browser, as IE7-IE9 all have the new hash value in `location.href` after changing it. There was a wrong assumption in the previous version of this code introduced by dca2317 and d707114. Adds more tests for angular#6976 Fixes angular#9235
Adds caching for url changes while a reload is happening, as browsers do not allow to read out the new location the browser is navigating to. Removes unnecessary caching from $browser, as IE7-IE9 all have the new hash value in `location.href` after changing it. There was a wrong assumption in the previous version of this code introduced by dca2317 and d707114. Adds more tests for angular#6976 Fixes angular#9235
Adds caching for url changes while a reload is happening, as browsers do not allow to read out the new location the browser is navigating to. Removes unnecessary caching from $browser, as IE7-IE9 all have the new hash value in `location.href` after changing it. There was a wrong assumption in the previous version of this code introduced by dca2317 and d707114. Adds more tests for angular#6976 Fixes angular#9235
Adds caching for url changes while a reload is happening, as browsers do not allow to read out the new location the browser is navigating to. Removes unnecessary caching from $browser, as IE7-IE9 all have the new hash value in `location.href` after changing it. There was a wrong assumption in the previous version of this code introduced by dca2317 and d707114. Adds more tests for angular#6976 Fixes angular#9235 Closes angular#9455
Adds caching for url changes while a reload is happening, as browsers do not allow to read out the new location the browser is navigating to. Removes unnecessary caching from $browser, as IE7-IE9 all have the new hash value in `location.href` after changing it. There was a wrong assumption in the previous version of this code introduced by dca2317 and d707114. Adds more tests for #6976 Fixes #9235 Closes #9470
Adds caching for url changes while a reload is happening, as browsers do not allow to read out the new location the browser is navigating to. Removes unnecessary caching from $browser, as IE7-IE9 all have the new hash value in `location.href` after changing it. There was a wrong assumption in the previous version of this code introduced by dca2317 and d707114. Adds more tests for angular#6976 Fixes angular#9235 Closes angular#9455
Was this issue resolved? We still get this issue on using "history.replaceState" |
This is supposed to be resolved for quite a while. If you are still having issues, please open a new bug report (providing the necessary info). |
I encountered this issue when using Dropbox Datastore API, which invokes
history.replaceState
after OAuth redirection. By adding a callback to$routeChangeStart
event, it seems the app is doing routing repeatedly.Only use
$location
may not always be possible when involving third party library or other app. Is there a workaround or imminent fix on this?Angular Version(s): 1.2.15
Browsers and Operating System: Chrome 33 on OS X 10.9
Reproduce Error: http://jsfiddle.net/7t7eK/ from #1417 with Angular 1.2.15
Related issues: #1417 , #3924
Error and trace that I got:
The text was updated successfully, but these errors were encountered: