fix(loading): potential race condition with showing and hiding loading in same watch cycle

This commit is contained in:
Perry Govier
2014-08-19 15:07:10 -05:00
parent 840c014b27
commit 65aece2aad
2 changed files with 6 additions and 2 deletions

View File

@@ -158,8 +158,11 @@ function($ionicLoadingConfig, $document, $ionicTemplateLoader, $ionicBackdrop, $
$ionicBackdrop.release();
$ionicBackdrop.getElement().removeClass('backdrop-loading');
}
self.element.removeClass('active');
$document[0].body.classList.remove('loading-active');
// wrapping in a timeout to make process asyncronous
$timeout(function(){
self.element.removeClass('active');
$document[0].body.classList.remove('loading-active');
}, 10);
setTimeout(function() {
!self.isShown && self.element.removeClass('visible');
}, 200);

View File

@@ -89,6 +89,7 @@ describe('$ionicLoading service', function() {
$timeout.flush();
expect(angular.element(document.body).hasClass('loading-active')).toBe(true);
loader.hide();
$timeout.flush();
expect(angular.element(document.body).hasClass('loading-active')).toBe(false);
}));