diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 47a0fa8db508..ccd3b22ca042 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -1761,9 +1761,7 @@ function radioInputType(scope, element, attr, ctrl) { if (doTrim) { value = trim(value); } - // Strict comparison would cause a BC - // eslint-disable-next-line eqeqeq - element[0].checked = (value == ctrl.$viewValue); + element[0].checked = (value === ctrl.$viewValue); }; attr.$observe('value', ctrl.$render); diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 15471354c56f..b943be57846b 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -3867,9 +3867,7 @@ describe('input', function() { expect($rootScope.color).toBe('blue'); }); - - // We generally use strict comparison. This tests behavior we cannot change without a BC - it('should use non-strict comparison the evaluate checked-ness', function() { + it('should treat the value as a string when evaluating checked-ness', function() { var inputElm = helper.compileInput( ''); @@ -3877,7 +3875,7 @@ describe('input', function() { expect(inputElm[0].checked).toBe(true); $rootScope.$apply('model = 0'); - expect(inputElm[0].checked).toBe(true); + expect(inputElm[0].checked).toBe(false); }); @@ -4131,6 +4129,18 @@ describe('input', function() { }); + it('should use strict comparison between model and value', function() { + $rootScope.selected = false; + var inputElm = helper.compileInput('' + + '' + + ''); + + expect(inputElm[0].checked).toBe(true); + expect(inputElm[1].checked).toBe(false); + expect(inputElm[2].checked).toBe(false); + }); + + it('should watch the expression', function() { var inputElm = helper.compileInput('');