Skip to content

Commit

Permalink
fix(select): use strict comparison for isSelected with selectAs
Browse files Browse the repository at this point in the history
  • Loading branch information
Narretz authored and caitp committed Nov 7, 2014
1 parent ed99821 commit 9e30594
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/directive/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
if (multiple) {
return isDefined(selectedSet.remove(callExpression(compareValueFn, key, value)));
} else {
return viewValue == callExpression(compareValueFn, key, value);
return viewValue === callExpression(compareValueFn, key, value);
}
};
}
Expand Down
14 changes: 14 additions & 0 deletions test/ng/directive/selectSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,20 @@ describe('select', function() {
expect(element.val()).toEqual('?');
expect(element.find('option').eq(0).attr('selected')).toEqual('selected');
});


it('should select the correct option for selectAs and falsy values', function() {
scope.values = [{value: 0, label: 'zero'}, {value: 1, label: 'one'}];
scope.selected = '';
createSelect({
'ng-model': 'selected',
'ng-options': 'option.value as option.label for option in values'
});

var option = element.find('option').eq(0);
expect(option.val()).toBe('?');
expect(option.text()).toBe('');
});
});


Expand Down

0 comments on commit 9e30594

Please sign in to comment.