From 6a9d9ae8784fe9cd98230247744f7bbb8a65479a Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 5 Nov 2016 14:26:13 -0500 Subject: [PATCH] fix(ui-sref-active): Use `$scope.$evalAsync` to apply css class - Reduce digests caused by removing `$timeout` calls - This seems to fix the broken behavior reported in both #2503 and #1997 Closes #2503 Closes #1997 Supercedes #2012 --- src/ng1/directives/stateDirectives.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ng1/directives/stateDirectives.ts b/src/ng1/directives/stateDirectives.ts index dde7b29db..90b909781 100644 --- a/src/ng1/directives/stateDirectives.ts +++ b/src/ng1/directives/stateDirectives.ts @@ -461,14 +461,11 @@ let uiSrefActive = ['$state', '$stateParams', '$interpolate', '$transitions', '$ } function addClass(el: IAugmentedJQuery, className: string) { - el.addClass(className); - $timeout(function () { - el.addClass(className); - }); + $scope.$evalAsync(() => el.addClass(className)); } function removeClass(el: IAugmentedJQuery, className: string) { - el.removeClass(className); + $scope.$evalAsync(() => el.removeClass(className)); } function anyMatch(state: State, params: Obj) {