Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

radioButton: integer values are not working because of strict comparison #1112

Closed
artch opened this issue Jan 5, 2015 · 4 comments
Closed
Assignees
Milestone

Comments

@artch
Copy link

artch commented Jan 5, 2015

If the md-radio-group model is defined as integer, it doesn't display checked status (md-checked class) because of the strict === value comparison here:

var checked = (rgCtrl.getViewValue() === attr.value);

Bug reproduce suite: http://codepen.io/artch/pen/jEVKYe?editors=101

@marcysutton
Copy link
Contributor

After looking at this JavaScript equality table, it looks like we can get away with == in this instance.

marcysutton pushed a commit that referenced this issue Jan 6, 2015
@ajoslin ajoslin added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Jan 6, 2015
@gkalpak
Copy link
Member

gkalpak commented Jan 6, 2015

I haven't looked properly into it, but using == should be avoided if possible.
Why not convert the viewValue to string ?

@marcysutton
Copy link
Contributor

Good question–that does seem like a wise idea given that == is basically the !important of JavaScript

@marcysutton
Copy link
Contributor

Upon closer inspection, we are going to stick with == and avoid string coercion. This approach is used on the input directive in Angular: https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L1290-L1310

@marcysutton marcysutton added resolution: fixed and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Jan 6, 2015
Akxe pushed a commit to Akxe/material that referenced this issue Apr 28, 2024
- remove use of old `-next` and `-rc` versions

Fixes angular#1112
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants