Skip to content
Permalink
Browse files

fix(input[radio]): use non-strict comparison for checkedness

This was introduced during the switch to ESLint (b1bc251#diff-c244afd8def7f268b16ee91a0341c4b2R1691), 
but it is a breaking change. In master, we made an exception
for this comparison when we introduced jshint eqeqeq (which was not
backported to 1.5.x).

PR (#15289)
  • Loading branch information
Narretz committed Oct 18, 2016
1 parent 660ee5b commit 9bda9943077481a8318bf1fa0a31c2682e784736
Showing with 14 additions and 1 deletion.
  1. +3 −1 src/ng/directive/input.js
  2. +11 −0 test/ng/directive/inputSpec.js
@@ -1753,7 +1753,9 @@ function radioInputType(scope, element, attr, ctrl) {

ctrl.$render = function() {
var value = attr.value;
element[0].checked = (value === ctrl.$viewValue);
// We generally use strict comparison. This is behavior we cannot change without a BC.
// eslint-disable-next-line eqeqeq
element[0].checked = (value == ctrl.$viewValue);
};

attr.$observe('value', ctrl.$render);
@@ -3871,6 +3871,17 @@ describe('input', function() {
});


it('should use non-strict comparison between model and value', function() {
$rootScope.selected = false;
var inputElm = helper.compileInput('<input type="radio" ng-model="selected" ng-value="false">' +
'<input type="radio" ng-model="selected" ng-value="\'\'">' +
'<input type="radio" ng-model="selected" ng-value="0">');

expect(inputElm[0].checked).toBe(true);
expect(inputElm[1].checked).toBe(true);
expect(inputElm[2].checked).toBe(true);
});

it('should watch the expression', function() {
var inputElm = helper.compileInput('<input type="radio" ng-model="selected" ng-value="value">');

0 comments on commit 9bda994

Please sign in to comment.
You can’t perform that action at this time.