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

Commit b245242

Browse files
c-vetterwesleycho
authored andcommitted
fix(buttons): fix uncheckable attribute
- Fix behavior of `uib-uncheckable` to agree with intention Closes #5451 Fixes #5412
1 parent 47e412e commit b245242

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

Diff for: src/buttons/buttons.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ angular.module('ui.bootstrap.buttons', [])
4444

4545
if (attrs.uibUncheckable) {
4646
scope.$watch(uncheckableExpr, function(uncheckable) {
47-
attrs.$set('uncheckable', uncheckable ? '' : null);
47+
attrs.$set('uncheckable', uncheckable ? '' : undefined);
4848
});
4949
}
5050
}

Diff for: src/buttons/test/buttons.spec.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,38 @@ describe('buttons', function() {
328328
$scope.uncheckable = false;
329329
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);
330330
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
331-
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
331+
expect(btns.eq(1).attr('uncheckable')).toBeUndefined();
332+
333+
expect($scope.model).toBeUndefined();
334+
335+
btns.eq(0).click();
336+
expect($scope.model).toEqual(1);
337+
338+
btns.eq(0).click();
339+
expect($scope.model).toEqual(1);
340+
341+
btns.eq(1).click();
342+
expect($scope.model).toEqual(2);
343+
344+
btns.eq(1).click();
345+
expect($scope.model).toEqual(2);
332346

333347
$scope.uncheckable = true;
334348
$scope.$digest();
335349
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
336350
expect(btns.eq(1).attr('uncheckable')).toBeDefined();
351+
352+
btns.eq(0).click();
353+
expect($scope.model).toEqual(1);
354+
355+
btns.eq(0).click();
356+
expect($scope.model).toEqual(1);
357+
358+
btns.eq(1).click();
359+
expect($scope.model).toEqual(2);
360+
361+
btns.eq(1).click();
362+
expect($scope.model).toBeNull();
337363
});
338364
});
339365
});

0 commit comments

Comments
 (0)