Select: get the latest cached option

pull/2466/head
Leopoldthecoder 2017-01-18 14:40:42 +08:00
parent 37ee8e9f88
commit b5d5922709
1 changed files with 7 additions and 1 deletions

View File

@ -363,7 +363,13 @@
},
getOption(value) {
const option = this.cachedOptions.filter(option => option.value === value)[0];
let option;
for (let i = 0, len = this.cachedOptions.length; i < len; i++) {
const cachedOption = this.cachedOptions[i];
if (cachedOption.value === value) {
option = cachedOption;
}
}
if (option) return option;
const label = typeof value === 'string' || typeof value === 'number'
? value : '';