Merge pull request #3742 from SergioCrisostomo/select-patches

Use label first if available
This commit is contained in:
Aresn 2018-05-29 15:43:48 +08:00 committed by GitHub
commit 1cd7dd8b3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -58,7 +58,7 @@
return (this.label) ? this.label : this.value;
},
optionLabel(){
return (this.$el && this.$el.textContent) || this.label;
return this.label || (this.$el && this.$el.textContent);
}
},
methods: {

View file

@ -129,9 +129,10 @@
};
const getOptionLabel = option => {
if (option.componentOptions.propsData.label) return option.componentOptions.propsData.label;
const textContent = (option.componentOptions.children || []).reduce((str, child) => str + (child.text || ''), '');
const innerHTML = getNestedProperty(option, 'data.domProps.innerHTML');
return option.componentOptions.propsData.label || textContent || (typeof innerHTML === 'string' ? innerHTML : '');
return textContent || (typeof innerHTML === 'string' ? innerHTML : '');
};