From 8044610dde8268d114d13265695344c3babdcb96 Mon Sep 17 00:00:00 2001 From: Piotr Kaminski Date: Mon, 23 May 2016 03:12:09 -0700 Subject: [PATCH 1/2] Guard against last minute removal of toBeActive spy Since the broadcast of `becameInactive` is synchronous, it's possible for the `toBeActive` spy to be removed by client code just before it gets activated. This change guards against this (admittedly extremely rare) scenario by treating the spy as if though it didn't exist in the first place. Note that it's possible that another spy should've been selected instead, then, but since the condition is so rare it's probably OK to wait until the next interval fires to recompute the actual active spy. --- src/services/spy-api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/spy-api.js b/src/services/spy-api.js index 38f10fb..9ed5063 100644 --- a/src/services/spy-api.js +++ b/src/services/spy-api.js @@ -53,6 +53,7 @@ angular.module('duScroll.spyAPI', ['duScroll.scrollContainerAPI']) angular.element(currentlyActive.getTargetElement()) ); } + if(toBeActive && !toBeActive.$element) toBeActive = undefined; if(toBeActive) { toBeActive.$element.addClass(duScrollActiveClass); $rootScope.$broadcast( From 626cd205e21fbdbe63dc1f98540d3ddd8d819bf2 Mon Sep 17 00:00:00 2001 From: Piotr Kaminski Date: Mon, 23 May 2016 13:18:35 -0700 Subject: [PATCH 2/2] Fix to follow project style --- src/services/spy-api.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/spy-api.js b/src/services/spy-api.js index 9ed5063..46b7040 100644 --- a/src/services/spy-api.js +++ b/src/services/spy-api.js @@ -53,7 +53,9 @@ angular.module('duScroll.spyAPI', ['duScroll.scrollContainerAPI']) angular.element(currentlyActive.getTargetElement()) ); } - if(toBeActive && !toBeActive.$element) toBeActive = undefined; + if(toBeActive && !toBeActive.$element) { + toBeActive = undefined; + } if(toBeActive) { toBeActive.$element.addClass(duScrollActiveClass); $rootScope.$broadcast(