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

Commit 9e30594

Browse files
Narretzcaitp
authored andcommitted
fix(select): use strict comparison for isSelected with selectAs
Closes #9639 Closes #9949
1 parent ed99821 commit 9e30594

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Diff for: src/ng/directive/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
483483
if (multiple) {
484484
return isDefined(selectedSet.remove(callExpression(compareValueFn, key, value)));
485485
} else {
486-
return viewValue == callExpression(compareValueFn, key, value);
486+
return viewValue === callExpression(compareValueFn, key, value);
487487
}
488488
};
489489
}

Diff for: test/ng/directive/selectSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,20 @@ describe('select', function() {
16291629
expect(element.val()).toEqual('?');
16301630
expect(element.find('option').eq(0).attr('selected')).toEqual('selected');
16311631
});
1632+
1633+
1634+
it('should select the correct option for selectAs and falsy values', function() {
1635+
scope.values = [{value: 0, label: 'zero'}, {value: 1, label: 'one'}];
1636+
scope.selected = '';
1637+
createSelect({
1638+
'ng-model': 'selected',
1639+
'ng-options': 'option.value as option.label for option in values'
1640+
});
1641+
1642+
var option = element.find('option').eq(0);
1643+
expect(option.val()).toBe('?');
1644+
expect(option.text()).toBe('');
1645+
});
16321646
});
16331647

16341648

0 commit comments

Comments
 (0)