Skip to content

Commit 218605f

Browse files
committed
fix(modal): clean up event listeners when hiding modal
1 parent 7873064 commit 218605f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: js/angular/service/modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl
218218

219219
// clean up event listeners
220220
if (self.positionView) {
221-
$window.addEventListener('resize', self._onWindowResize);
221+
$window.removeEventListener('resize', self._onWindowResize);
222222
}
223223

224224
return $timeout(function() {

Diff for: test/unit/angular/service/popover.unit.js

+10
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ describe('Ionic Popover', function() {
9494
expect(angular.element(document.body).hasClass('popover-open')).toBe(false);
9595
}));
9696

97+
it('expect hide to remove event listeners', inject(function($window) {
98+
var instance = popover.fromTemplate('<div class="popover">hi</div>');
99+
spyOn($window,'removeEventListener');
100+
instance.show();
101+
timeout.flush();
102+
instance.hide();
103+
timeout.flush();
104+
expect($window.removeEventListener).toHaveBeenCalled();
105+
}));
106+
97107
it('should animate leave and destroy scope on remove', inject(function($animate) {
98108
var instance = popover.fromTemplate('<div class="popover"></div>');
99109
spyOn($animate, 'leave').andCallFake(function(el, cb) { cb(); });

0 commit comments

Comments
 (0)