Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(select): unable to switch between falsy options (#9945)
Browse files Browse the repository at this point in the history
Fixes #9533.
  • Loading branch information
crisbeto authored and kara committed Jan 4, 2017
1 parent b38d928 commit 54a1d0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/select/select.js
Expand Up @@ -889,7 +889,7 @@ function SelectMenuDirective($parse, $mdUtil, $mdConstant, $mdTheming) {
var newVal = self.isMultiple ? values : values[0];
var prevVal = self.ngModel.$modelValue;

if (usingTrackBy ? !angular.equals(prevVal, newVal) : prevVal != newVal) {
if (usingTrackBy ? !angular.equals(prevVal, newVal) : prevVal !== newVal) {
self.ngModel.$setViewValue(newVal);
self.ngModel.$render();
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/select/select.spec.js
Expand Up @@ -798,6 +798,15 @@ describe('<md-select>', function() {
expect($rootScope.model).toBe(4);
});

it('should allow switching between falsy options', inject(function($rootScope) {
$rootScope.model = false;
var el = setupSelect('ng-model="$root.model"', [false, 0]);

openSelect(el);
clickOption(el, 1);

expect($rootScope.model).toBe(0);
}));
});
});

Expand Down

0 comments on commit 54a1d0d

Please sign in to comment.