Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Tab active function fix #1562

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ angular.module('ui.bootstrap.tabs', [])
var getActive, setActive;
if (attrs.active) {
getActive = $parse(attrs.active);
setActive = getActive.assign;
setActive = getActive.assign || angular.noop;

scope.$parent.$watch(getActive, function updateActive(value, oldVal) {
// Avoid re-initializing scope.active as it is already initialized
// below. (watcher is called async during init with value ===
Expand Down
30 changes: 30 additions & 0 deletions src/tabs/test/tabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,36 @@ describe('tabs', function() {
}));
});

describe('active', function() {
var generateElm;

beforeEach(inject(function($compile, $rootScope) {
scope = $rootScope.$new();

generateElm = function(activeAttr) {
elm = $compile([
'<tabset>',
' <tab active="' + activeAttr + '">',
' <tab-heading><b>heading</b></tab-heading>',
' </tab>',
'</tabset>'
].join('\n'))(scope);

scope.$apply();

return elm;
};
}));

it('should allow a function as an argument', function() {
scope.isActive = jasmine.createSpy();

elm = generateElm('isActive()');

expect(scope.isActive).toHaveBeenCalled();
});
});

describe('disabled', function() {
beforeEach(inject(function($compile, $rootScope) {
scope = $rootScope.$new();
Expand Down