Skip to content

Commit

Permalink
fix(ui-sref-active): Use $scope.$evalAsync to apply css class
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
christopherthielen committed Nov 5, 2016
1 parent 27eb5e9 commit 6a9d9ae
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/ng1/directives/stateDirectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6a9d9ae

Please sign in to comment.