Skip to content

Commit

Permalink
fix(uiSrefActive): update the active classes when compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
fpipita committed Jan 7, 2016
1 parent d31b333 commit 7c91403
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/stateDirectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ function $StateRefActiveDirective($state, $stateParams, $interpolate) {
function removeClass(el, className) { el.removeClass(className); }
function anyMatch(state, params) { return $state.includes(state.name, params); }
function exactMatch(state, params) { return $state.is(state.name, params); }

update();
}]
};
}
Expand Down
10 changes: 10 additions & 0 deletions test/stateDirectivesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,16 @@ describe('uiSrefActive', function() {
expect(el[0].className).toMatch(/admin/);
expect(el[0].className).not.toMatch(/contacts/);
}));

it('should update the active classes when compiled', inject(function($compile, $rootScope, $document, $state, $q) {
$state.transitionTo('admin.roles');
$q.flush();
timeoutFlush();
el = $compile('<div ui-sref-active="{active: \'admin.roles\'}"/>')($rootScope);
$rootScope.$digest();
timeoutFlush();
expect(el.hasClass('active')).toBeTruthy();
}));
});
});

Expand Down

0 comments on commit 7c91403

Please sign in to comment.