Use label first if available

This commit is contained in:
Sergio Crisostomo 2018-05-29 08:40:45 +02:00
parent 4cccdf1fd5
commit 1b39f56967
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 : '');
};