Skip to content

Commit

Permalink
fix(modal): clean up event listeners when hiding modal
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygovier committed Apr 14, 2015
1 parent 7873064 commit 218605f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/angular/service/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl

// clean up event listeners
if (self.positionView) {
$window.addEventListener('resize', self._onWindowResize);
$window.removeEventListener('resize', self._onWindowResize);
}

return $timeout(function() {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/angular/service/popover.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ describe('Ionic Popover', function() {
expect(angular.element(document.body).hasClass('popover-open')).toBe(false);
}));

it('expect hide to remove event listeners', inject(function($window) {
var instance = popover.fromTemplate('<div class="popover">hi</div>');
spyOn($window,'removeEventListener');
instance.show();
timeout.flush();
instance.hide();
timeout.flush();
expect($window.removeEventListener).toHaveBeenCalled();
}));

it('should animate leave and destroy scope on remove', inject(function($animate) {
var instance = popover.fromTemplate('<div class="popover"></div>');
spyOn($animate, 'leave').andCallFake(function(el, cb) { cb(); });
Expand Down

0 comments on commit 218605f

Please sign in to comment.