From 5f89bbd6c5825082fdb8c0b9d5ba0df83b37d2bd Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Tue, 18 Oct 2016 11:00:10 +0200 Subject: [PATCH] fix(input[radio]): use non-strict comparison for checkedness This was introduced during the switch to ESLint, but it is a breaking change. --- src/ng/directive/input.js | 4 +++- test/ng/directive/inputSpec.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index da3b4944d45f..7b5882d48942 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.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); diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 1d81f9a5efcf..1de73f9266b2 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -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('' + + '' + + ''); + + 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('');