Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(input[radio]): use strict comparison when evaluating checked-ness #15288

Merged
merged 1 commit into from
Nov 8, 2016

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Oct 18, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Fix

What is the current behavior? (You can also link to an open issue here)
When using input[radio], the checked status is determined by doing
a non-strict comparison between the value of the input and the ngModel.$viewValue. This can
lead to inconsistencies when using values such as 0 and false.

Does this PR introduce a breaking change?
Yes

Please check if the PR fulfills these requirements

Other information:

Closes #15283

BREAKING CHANGE:

When using input[radio], the checked status is now determined by doing
a strict comparison between the value of the input and the ngModel.$viewValue.
Previously, this was a non-strict comparison (==).

This means in the following examples the radio is no longer checked:

  <!-- this.selected = 0 -->
  <input type="radio" ng-model="$ctrl.selected" value="0" >

  <!-- this.selected = 0; this.value = false; -->
  <input type="radio" ng-model="$ctrl.selected" ng-value="$ctrl.value" >

The migration strategy is to convert values that matched with non-strict
conversion so that they will match with strict conversion.

Closes angular#15283

BREAKING CHANGE:

When using input[radio], the checked status is now determined by doing
a strict comparison between the value of the input and the ngModel.$viewValue.
Previously, this was a non-strict comparison (==).

This means in the following examples the radio is no longer checked:

```
  <!-- this.selected = 0 -->
  <input type="radio" ng-model="$ctrl.selected" value="0" >

  <!-- this.selected = 0; this.value = false; -->
  <input type="radio" ng-model="$ctrl.selected" ng-value="$ctrl.value" >
```

The migration strategy is to convert values that matched with non-strict
conversion so that they will match with strict conversion.
@mgol
Copy link
Member

mgol commented Nov 7, 2016

Milestone moved back to 1.6.0-rc.1.

@Narretz Narretz merged commit 5ac7dae into angular:master Nov 8, 2016
ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
Closes angular#15283
Closes angular#15288

BREAKING CHANGE:

When using input[radio], the checked status is now determined by doing
a strict comparison between the value of the input and the ngModel.$viewValue.
Previously, this was a non-strict comparison (==).

This means in the following examples the radio is no longer checked:

```
  <!-- this.selected = 0 -->
  <input type="radio" ng-model="$ctrl.selected" value="0" >

  <!-- this.selected = 0; this.value = false; -->
  <input type="radio" ng-model="$ctrl.selected" ng-value="$ctrl.value" >
```

The migration strategy is to convert values that matched with non-strict
conversion so that they will match with strict conversion.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing Type Coercion with ng-value
3 participants