Commit 220161f5edb25fea9098e65f5a1e7df12f63078f

Authored by Sergio Crisostomo
1 parent 7d14e70c

Clean up empty/null entries

Showing 1 changed file with 13 additions and 13 deletions   Show diff stats
src/components/select/select.vue
@@ -56,12 +56,12 @@ @@ -56,12 +56,12 @@
56 > 56 >
57 <ul v-show="showNotFoundLabel" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul> 57 <ul v-show="showNotFoundLabel" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul>
58 <ul :class="prefixCls + '-dropdown-list'"> 58 <ul :class="prefixCls + '-dropdown-list'">
59 - <functional-options  
60 - v-if="(!remote) || (remote && !loading)"  
61 - :options="selectOptions"  
62 - :slot-update-hook="updateSlotOptions"  
63 - :slot-options="slotOptions"  
64 - ></functional-options> 59 + <functional-options
  60 + v-if="(!remote) || (remote && !loading)"
  61 + :options="selectOptions"
  62 + :slot-update-hook="updateSlotOptions"
  63 + :slot-options="slotOptions"
  64 + ></functional-options>
65 </ul> 65 </ul>
66 <ul v-show="loading" :class="[prefixCls + '-loading']">{{ localeLoadingText }}</ul> 66 <ul v-show="loading" :class="[prefixCls + '-loading']">{{ localeLoadingText }}</ul>
67 </Drop> 67 </Drop>
@@ -207,7 +207,7 @@ @@ -207,7 +207,7 @@
207 207
208 // set the initial values if there are any 208 // set the initial values if there are any
209 if (this.values.length > 0 && !this.remote && this.selectOptions.length > 0){ 209 if (this.values.length > 0 && !this.remote && this.selectOptions.length > 0){
210 - this.values = this.values.map(this.getOptionData); 210 + this.values = this.values.map(this.getOptionData).filter(Boolean);
211 } 211 }
212 212
213 if (this.values.length > 0 && this.selectOptions.length === 0){ 213 if (this.values.length > 0 && this.selectOptions.length === 0){
@@ -307,7 +307,7 @@ @@ -307,7 +307,7 @@
307 const slotOptions = (this.slotOptions || []); 307 const slotOptions = (this.slotOptions || []);
308 let optionCounter = -1; 308 let optionCounter = -1;
309 const currentIndex = this.focusIndex; 309 const currentIndex = this.focusIndex;
310 - const selectedValues = this.values.map(({value}) => value); 310 + const selectedValues = this.values.filter(Boolean).map(({value}) => value);
311 if (this.autoComplete) { 311 if (this.autoComplete) {
312 const copyChildren = (node, fn) => { 312 const copyChildren = (node, fn) => {
313 return { 313 return {
@@ -398,7 +398,7 @@ @@ -398,7 +398,7 @@
398 const {multiple, value} = this; 398 const {multiple, value} = this;
399 let initialValue = Array.isArray(value) ? value : [value]; 399 let initialValue = Array.isArray(value) ? value : [value];
400 if (!multiple && (typeof initialValue[0] === 'undefined' || String(initialValue[0]).trim() === '')) initialValue = []; 400 if (!multiple && (typeof initialValue[0] === 'undefined' || String(initialValue[0]).trim() === '')) initialValue = [];
401 - return initialValue; 401 + return initialValue.filter(Boolean);
402 }, 402 },
403 processOption(option, values, isFocused){ 403 processOption(option, values, isFocused){
404 if (!option.componentOptions) return option; 404 if (!option.componentOptions) return option;
@@ -580,7 +580,7 @@ @@ -580,7 +580,7 @@
580 580
581 if (value === '') this.values = []; 581 if (value === '') this.values = [];
582 else if (JSON.stringify(value) !== JSON.stringify(publicValue)) { 582 else if (JSON.stringify(value) !== JSON.stringify(publicValue)) {
583 - this.$nextTick(() => this.values = getInitialValue().map(getOptionData)); 583 + this.$nextTick(() => this.values = getInitialValue().map(getOptionData).filter(Boolean));
584 } 584 }
585 }, 585 },
586 values(now, before){ 586 values(now, before){
@@ -592,8 +592,8 @@ @@ -592,8 +592,8 @@
592 // v-model is always just the value, event with labelInValue === true 592 // v-model is always just the value, event with labelInValue === true
593 const vModelValue = this.labelInValue ? 593 const vModelValue = this.labelInValue ?
594 (this.multiple ? this.publicValue.map(({value}) => value) 594 (this.multiple ? this.publicValue.map(({value}) => value)
595 - :  
596 - this.publicValue.value) : this.publicValue; 595 + :
  596 + this.publicValue.value) : this.publicValue;
597 this.$emit('input', vModelValue); // to update v-model 597 this.$emit('input', vModelValue); // to update v-model
598 this.$emit('on-change', this.publicValue); 598 this.$emit('on-change', this.publicValue);
599 this.dispatch('FormItem', 'on-form-change', this.publicValue); 599 this.dispatch('FormItem', 'on-form-change', this.publicValue);
@@ -659,7 +659,7 @@ @@ -659,7 +659,7 @@
659 }, 659 },
660 selectOptions(){ 660 selectOptions(){
661 if (this.hasExpectedValue){ 661 if (this.hasExpectedValue){
662 - this.values = this.values.map(this.getOptionData); 662 + this.values = this.values.map(this.getOptionData).filter(Boolean);
663 this.hasExpectedValue = false; 663 this.hasExpectedValue = false;
664 } 664 }
665 665