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

fix(select): use strict comparison for isSelected with selectAs #9949

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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