Skip to content

Commit

Permalink
fix(karma): adding checks to prevent null pointers in clean-up phase
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Bucholtz committed Apr 6, 2016
1 parent e5d9d14 commit 964a7d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 11 additions & 7 deletions js/angular/controller/refresherController.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,17 @@ IonicModule
};

function destroy() {
ionic.off(touchStartEvent, handleTouchstart, scrollChild);
ionic.off(touchMoveEvent, handleTouchmove, scrollChild);
ionic.off(touchEndEvent, handleTouchend, scrollChild);
ionic.off('mousedown', handleMousedown, scrollChild);
ionic.off('mousemove', handleTouchmove, scrollChild);
ionic.off('mouseup', handleTouchend, scrollChild);
ionic.off('scroll', handleScroll, scrollParent);
if ( scrollChild ){
ionic.off(touchStartEvent, handleTouchstart, scrollChild);
ionic.off(touchMoveEvent, handleTouchmove, scrollChild);
ionic.off(touchEndEvent, handleTouchend, scrollChild);
ionic.off('mousedown', handleMousedown, scrollChild);
ionic.off('mousemove', handleTouchmove, scrollChild);
ionic.off('mouseup', handleTouchend, scrollChild);
}
if ( scrollParent ){
ionic.off('scroll', handleScroll, scrollParent);
}
scrollParent = null;
scrollChild = null;
}
Expand Down
6 changes: 4 additions & 2 deletions js/angular/controller/scrollController.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ function($scope,
deregisterInstance();
scrollView && scrollView.__cleanup && scrollView.__cleanup();
angular.element($window).off('resize', resize);
$element.off('scroll', scrollFunc);
scrollView = self.scrollView = scrollViewOptions = self._scrollViewOptions = scrollViewOptions.el = self._scrollViewOptions.el = $element = self.$element = element = null;
if ( $element ){
$element.off('scroll', scrollFunc);
scrollView = self.scrollView = scrollViewOptions = self._scrollViewOptions = scrollViewOptions.el = self._scrollViewOptions.el = $element = self.$element = element = null;
}
});

$timeout(function() {
Expand Down

0 comments on commit 964a7d5

Please sign in to comment.