-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($location): do not get caught in infinite digest in IE9 #12083
Conversation
@hamfastgamgee can you take a look at this alternative? |
$location.path('/').replace(); | ||
} | ||
}); | ||
$rootScope.$digest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check that the change handler actually gets called and that the path is updated correctly
Well, leaving aside the failed tests, I can verify that it does in fact fix my case. I had tried a similar fix previously (never exactly this; it was mostly removing the sameBase check) and had at least three failed tests, but it appears that your fix at least satisfies most browsers on travis. :) |
ba391d2
to
f7b1a6c
Compare
OK, I'll fix up these tests and then if you can give it a once-over, I'll be able to merge it tomorrow |
Sure thing. Can this please be backported into the 1.3.x branch as well?
My app might be able to go up to 1.4.x, but at present we're not allocating
any time to do the level of regression testing that would make our business
users comfortable. (I realize it should be a relatively easy upgrade when
we have that time.)
|
I think this should be able to be back-ported |
Updated. |
LGTM. Still works in my app. :) |
63b6e76
to
8f1a81e
Compare
If Travis is green by the morning I will merge. |
lgtm especially with all the tests! |
And it's in! Backporting to 1.3... |
Thanks to @hamfastgamgee for getting this fix in place. Closes #11439 Closes #11675 Closes #11935 Closes #12083
Thanks to @hamfastgamgee for getting this fix in place. Closes angular#11439 Closes angular#11675 Closes angular#11935 Closes angular#12083
The problem appears to occur when we have triggered a reload (via replace()) that updates the
reloadLocation
but then before the reload happens we trigger another change to the URL that would not have triggered a reload if we had already reloaded. In this case, the$browser
is ignoring thereloadLocation
because it thinks that we will no longer reload.So to be more explicit:
Navigate to http://my.server.com/Home
Because we are on IE9 this get rewritten (with replace()) to http://my.server.com/#/Home, which would cause a reload on IE9
The SuccessChangeHandler kicks in and then changes the $location.path to /, i.e. the URL gets changed to http://my.server.com/#/`.
Since http://my.server.com/#/Home -> http://my.server.com/#/ would not normally trigger a reload we don't update the reloadLocation, which gets stuck at http://my.server.com/#/Home
We get stuck in an infinite digest as the $location keeps trying to update the URL to http://my.server.com/#/ but failing because the reloadLocation is stuck at http://my.server.com/#/Home
This is why @hamfastgamgee's fix appears to work. When we see that we are in an infinite loop and there is a reloadLocation then we force it to change to the proper URL.
A better solution is simply to realize that we are updating a URL in $browser that is expected to cause a reload by changing the line at https://github.com/angular/angular.js/blob/v1.4.0/src/ng/browser.js#L150:
to
In other words we check not only whether the base has changed but also whether we are in the middle of a reload any way.
Closes #11439
Closes #11935
Closes #11675