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

Commit

Permalink
fix(buttons): fix uncheckable attribute
Browse files Browse the repository at this point in the history
- Fix behavior of `uib-uncheckable` to agree with intention

Closes #5451
Fixes #5412
  • Loading branch information
c-vetter authored and wesleycho committed Feb 24, 2016
1 parent 47e412e commit b245242
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/buttons/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ angular.module('ui.bootstrap.buttons', [])

if (attrs.uibUncheckable) {
scope.$watch(uncheckableExpr, function(uncheckable) {
attrs.$set('uncheckable', uncheckable ? '' : null);
attrs.$set('uncheckable', uncheckable ? '' : undefined);
});
}
}
Expand Down
28 changes: 27 additions & 1 deletion src/buttons/test/buttons.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,38 @@ describe('buttons', function() {
$scope.uncheckable = false;
var btns = compileButtons('<button ng-model="model" uib-btn-radio="1">click1</button><button ng-model="model" uib-btn-radio="2" uib-uncheckable="uncheckable">click2</button>', $scope);
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
expect(btns.eq(1).attr('uncheckable')).toBeUndefined();

expect($scope.model).toBeUndefined();

btns.eq(0).click();
expect($scope.model).toEqual(1);

btns.eq(0).click();
expect($scope.model).toEqual(1);

btns.eq(1).click();
expect($scope.model).toEqual(2);

btns.eq(1).click();
expect($scope.model).toEqual(2);

$scope.uncheckable = true;
$scope.$digest();
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
expect(btns.eq(1).attr('uncheckable')).toBeDefined();

btns.eq(0).click();
expect($scope.model).toEqual(1);

btns.eq(0).click();
expect($scope.model).toEqual(1);

btns.eq(1).click();
expect($scope.model).toEqual(2);

btns.eq(1).click();
expect($scope.model).toBeNull();
});
});
});
Expand Down

0 comments on commit b245242

Please sign in to comment.