Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 77e6acb

Browse files
fix($dialog): fix $apply in progres on $location change
1 parent 474ce52 commit 77e6acb

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

src/dialog/dialog.js

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ dialogModule.provider("$dialog", function(){
9696

9797
this.handleLocationChange = function() {
9898
self.close();
99-
self.$scope.$apply();
10099
};
101100
}
102101

src/dialog/test/dialog.spec.js

+17-14
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ describe('Given ui.bootstrap.dialog', function(){
6060
provider.options({});
6161
};
6262

63-
var changeLocation = function() {
64-
$rootScope.$broadcast('$locationChangeSuccess');
65-
$rootScope.$apply();
66-
};
6763

6864
var dialogShouldBeClosed = function(){
6965
it('should not include a backdrop in the DOM', function(){
@@ -75,7 +71,7 @@ describe('Given ui.bootstrap.dialog', function(){
7571
});
7672

7773
it('should return false for isOpen()', function(){
78-
expect(dialog.isOpen()).toBe(false);
74+
expect(dialog.isOpen()).toBeFalsy();
7975
});
8076
};
8177

@@ -292,16 +288,23 @@ describe('Given ui.bootstrap.dialog', function(){
292288
expect($document.find('body > div.modal > div.modal-header').length).toBe(1);
293289
});
294290
});
295-
296-
describe('When dialog is open and location changes', function(){
297-
beforeEach(function(){
298-
createDialog({template:template});
299-
openDialog();
300-
changeLocation();
301-
});
302291

303-
dialogShouldBeClosed();
304-
});
292+
describe('When dialog is open and location changes', function () {
293+
294+
var changeLocation = function () {
295+
$rootScope.$apply(function(){
296+
$rootScope.$broadcast('$locationChangeSuccess');
297+
});
298+
};
299+
300+
beforeEach(function () {
301+
createDialog({template: template});
302+
openDialog();
303+
changeLocation();
304+
});
305+
306+
dialogShouldBeClosed();
307+
});
305308

306309
describe('when opening it with a template containing white-space', function(){
307310

src/modal/test/modal.spec.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ describe('Give ui.boostrap.modal', function() {
170170
expect($scope.modalShown).not.toBeTruthy();
171171
});
172172

173-
it('should update the model if the location change is successful', function() {
174-
$rootScope.$broadcast('$locationChangeSuccess');
175-
$scope.$digest();
176-
expect($scope.modalShown).not.toBeTruthy();
177-
});
173+
it('should update the model if the location change is successful', function () {
174+
$rootScope.$apply(function(){
175+
$rootScope.$broadcast('$locationChangeSuccess');
176+
});
177+
expect($scope.modalShown).toBeFalsy();
178+
});
178179
});
179180
});

0 commit comments

Comments
 (0)