From cffe631866d093226aa8b8a54122de3d21a23646 Mon Sep 17 00:00:00 2001 From: Perry Govier Date: Fri, 26 Sep 2014 15:26:01 -0500 Subject: [PATCH] fix(loading): subsequent calls use config defaults and not last call's options. Fixes #2066, #2088 --- js/angular/service/loading.js | 2 +- test/unit/angular/service/loading.unit.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/js/angular/service/loading.js b/js/angular/service/loading.js index fe7f73cf0c..3166614670 100644 --- a/js/angular/service/loading.js +++ b/js/angular/service/loading.js @@ -177,7 +177,7 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop, } function showLoader(options) { - options = extend($ionicLoadingConfig || {}, options || {}); + options = extend({}, $ionicLoadingConfig || {}, options || {}); var delay = options.delay || options.showDelay || 0; //If loading.show() was called previously, cancel it and show with our new options diff --git a/test/unit/angular/service/loading.unit.js b/test/unit/angular/service/loading.unit.js index 36f0a9cf69..fe4c328259 100644 --- a/test/unit/angular/service/loading.unit.js +++ b/test/unit/angular/service/loading.unit.js @@ -216,5 +216,19 @@ describe('$ionicLoadingConfig', function() { expect(loader.element.text()).toBe('some other template'); })); + it('should use the original defaults with subsequent calls', inject(function($ionicLoading, $timeout) { + var loader = TestUtil.unwrapPromise($ionicLoading._getLoader()); + $ionicLoading.show({ + template: 'some other template' + }); + $timeout.flush(); + expect(loader.element.text()).toBe('some other template'); + $ionicLoading.hide(); + $timeout.flush(); + $ionicLoading.show(); + $timeout.flush(); + expect(loader.element.text()).toBe('some template'); + })); + });