Skip to content

Commit 964a7d5

Browse files
author
Dan Bucholtz
committed
fix(karma): adding checks to prevent null pointers in clean-up phase
1 parent e5d9d14 commit 964a7d5

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Diff for: js/angular/controller/refresherController.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,17 @@ IonicModule
306306
};
307307

308308
function destroy() {
309-
ionic.off(touchStartEvent, handleTouchstart, scrollChild);
310-
ionic.off(touchMoveEvent, handleTouchmove, scrollChild);
311-
ionic.off(touchEndEvent, handleTouchend, scrollChild);
312-
ionic.off('mousedown', handleMousedown, scrollChild);
313-
ionic.off('mousemove', handleTouchmove, scrollChild);
314-
ionic.off('mouseup', handleTouchend, scrollChild);
315-
ionic.off('scroll', handleScroll, scrollParent);
309+
if ( scrollChild ){
310+
ionic.off(touchStartEvent, handleTouchstart, scrollChild);
311+
ionic.off(touchMoveEvent, handleTouchmove, scrollChild);
312+
ionic.off(touchEndEvent, handleTouchend, scrollChild);
313+
ionic.off('mousedown', handleMousedown, scrollChild);
314+
ionic.off('mousemove', handleTouchmove, scrollChild);
315+
ionic.off('mouseup', handleTouchend, scrollChild);
316+
}
317+
if ( scrollParent ){
318+
ionic.off('scroll', handleScroll, scrollParent);
319+
}
316320
scrollParent = null;
317321
scrollChild = null;
318322
}

Diff for: js/angular/controller/scrollController.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ function($scope,
8484
deregisterInstance();
8585
scrollView && scrollView.__cleanup && scrollView.__cleanup();
8686
angular.element($window).off('resize', resize);
87-
$element.off('scroll', scrollFunc);
88-
scrollView = self.scrollView = scrollViewOptions = self._scrollViewOptions = scrollViewOptions.el = self._scrollViewOptions.el = $element = self.$element = element = null;
87+
if ( $element ){
88+
$element.off('scroll', scrollFunc);
89+
scrollView = self.scrollView = scrollViewOptions = self._scrollViewOptions = scrollViewOptions.el = self._scrollViewOptions.el = $element = self.$element = element = null;
90+
}
8991
});
9092

9193
$timeout(function() {

0 commit comments

Comments
 (0)