From ca3e4c306af3e4a49670a379d759f0448b42ca95 Mon Sep 17 00:00:00 2001 From: Marcy Sutton Date: Tue, 6 Jan 2015 11:09:14 -0800 Subject: [PATCH] fix(mdRadioButton): Loosen equality check Closes #1112 --- .../radioButton/demoBasicUsage/script.js | 4 ++-- src/components/radioButton/radioButton.js | 2 +- src/components/radioButton/radioButton.spec.js | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/radioButton/demoBasicUsage/script.js b/src/components/radioButton/demoBasicUsage/script.js index 3e6d07c0954..88f0ffb8ed0 100644 --- a/src/components/radioButton/demoBasicUsage/script.js +++ b/src/components/radioButton/demoBasicUsage/script.js @@ -9,8 +9,8 @@ angular.module('radioDemo1', ['ngMaterial']) }; $scope.radioData = [ - { label: '1', value: '1' }, - { label: '2', value: '2' }, + { label: '1', value: 1 }, + { label: '2', value: 2 }, { label: '3', value: '3', isDisabled: true }, { label: '4', value: '4' } ]; diff --git a/src/components/radioButton/radioButton.js b/src/components/radioButton/radioButton.js index 2b34a50ef2a..cbf1cc77d28 100644 --- a/src/components/radioButton/radioButton.js +++ b/src/components/radioButton/radioButton.js @@ -246,7 +246,7 @@ function mdRadioButtonDirective($mdAria, $mdUtil, $mdTheming) { } function render() { - var checked = (rgCtrl.getViewValue() === attr.value); + var checked = (rgCtrl.getViewValue() == attr.value); if (checked === lastChecked) { return; } diff --git a/src/components/radioButton/radioButton.spec.js b/src/components/radioButton/radioButton.spec.js index 6e7fbe6562d..d154c0f69fc 100644 --- a/src/components/radioButton/radioButton.spec.js +++ b/src/components/radioButton/radioButton.spec.js @@ -20,6 +20,20 @@ describe('radioButton', function() { expect(rbElements.eq(1).hasClass(CHECKED_CSS)).toEqual(true); })); + it('should support mixed values', inject(function($compile, $rootScope) { + var element = $compile('' + + '' + + '' + + '')($rootScope); + + $rootScope.$apply(function(){ + $rootScope.value = 1; + }); + + var rbElements = element.find('md-radio-button'); + expect(rbElements.eq(0).hasClass(CHECKED_CSS)).toEqual(true); + })); + it('should set roles', inject(function($compile, $rootScope) { var element = $compile('' +