aboutsummaryrefslogtreecommitdiffstats
path: root/src/service
diff options
context:
space:
mode:
authorVojta Jina2012-01-13 16:38:08 -0800
committerVojta Jina2012-01-14 11:23:12 -0800
commitc49b8a2db5d916a9213547125af996d6c853230c (patch)
treed8e4d639306790d2466ba01b15410342db4c2d7c /src/service
parent5cdfe45aa3e50fabad44009c1b8511253c6e4915 (diff)
downloadangular.js-c49b8a2db5d916a9213547125af996d6c853230c.tar.bz2
fix($location): do not $digest if browser's url change fired within $apply/$digest
Chrome (probably other browsers as well) fires 'hashchange' event synchronously, so if you change raw location from within $apply/$digest, we don't want to $apply twice. (It would throw an exception)
Diffstat (limited to 'src/service')
-rw-r--r--src/service/location.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/service/location.js b/src/service/location.js
index d0ae9de7..3e8ba0c3 100644
--- a/src/service/location.js
+++ b/src/service/location.js
@@ -530,8 +530,10 @@ function $LocationProvider(){
// update $location when $browser url changes
$browser.onUrlChange(function(newUrl) {
if (currentUrl.absUrl() != newUrl) {
- currentUrl.$$parse(newUrl);
- $rootScope.$apply();
+ $rootScope.$evalAsync(function() {
+ currentUrl.$$parse(newUrl);
+ });
+ if (!$rootScope.$$phase) $rootScope.$digest();
}
});