Allow empty values

This commit is contained in:
Rico Sta. Cruz 2016-12-29 15:06:35 +08:00
parent 6c29011d9b
commit 135ca8c1f8
No known key found for this signature in database
GPG key ID: CAAD38AE2962619A
2 changed files with 16 additions and 1 deletions

View file

@ -1940,7 +1940,7 @@ class Choices {
* @private
*/
_addChoice(isSelected, isDisabled, value, label, groupId = -1) {
if (!value) return;
if (typeof value === 'undefined' || value === null) return;
// Generate unique id
const choices = this.store.getChoices();

View file

@ -640,6 +640,21 @@ describe('Choices', () => {
expect(choices[choices.length - 2].value).toEqual('Child Five');
});
it('should handle setChoices() with blank values', function() {
this.choices.setChoices([{
label: 'Choice one',
value: 'one'
}, {
label: 'Choice two',
value: ''
}], 'value', 'label', true);
const choices = this.choices.currentState.choices;
expect(choices[0].value).toEqual('one');
expect(choices[1].value).toEqual('');
});
it('should handle clearStore()', function() {
this.choices.clearStore();