diff options
| author | Vojta Jina | 2012-01-13 16:38:08 -0800 | 
|---|---|---|
| committer | Vojta Jina | 2012-01-14 11:23:12 -0800 | 
| commit | c49b8a2db5d916a9213547125af996d6c853230c (patch) | |
| tree | d8e4d639306790d2466ba01b15410342db4c2d7c /src/service/location.js | |
| parent | 5cdfe45aa3e50fabad44009c1b8511253c6e4915 (diff) | |
| download | angular.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/location.js')
| -rw-r--r-- | src/service/location.js | 6 | 
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();        }      });  | 
