Skip to content

Commit dfd1078

Browse files
Merge pull request #2447 from fpipita/master
fix(uiSrefActive): update the active classes when compiled
2 parents e92a929 + 7c91403 commit dfd1078

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/stateDirectives.js

+2
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ function $StateRefActiveDirective($state, $stateParams, $interpolate) {
372372
function removeClass(el, className) { el.removeClass(className); }
373373
function anyMatch(state, params) { return $state.includes(state.name, params); }
374374
function exactMatch(state, params) { return $state.is(state.name, params); }
375+
376+
update();
375377
}]
376378
};
377379
}

test/stateDirectivesSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,16 @@ describe('uiSrefActive', function() {
680680
expect(el[0].className).toMatch(/admin/);
681681
expect(el[0].className).not.toMatch(/contacts/);
682682
}));
683+
684+
it('should update the active classes when compiled', inject(function($compile, $rootScope, $document, $state, $q) {
685+
$state.transitionTo('admin.roles');
686+
$q.flush();
687+
timeoutFlush();
688+
el = $compile('<div ui-sref-active="{active: \'admin.roles\'}"/>')($rootScope);
689+
$rootScope.$digest();
690+
timeoutFlush();
691+
expect(el.hasClass('active')).toBeTruthy();
692+
}));
683693
});
684694
});
685695

0 commit comments

Comments
 (0)