Forráskód Böngészése

Select: get the latest cached option

Leopoldthecoder 8 éve
szülő
commit
b5d5922709
1 módosított fájl, 7 hozzáadás és 1 törlés
  1. 7 1
      packages/select/src/select.vue

+ 7 - 1
packages/select/src/select.vue

@@ -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 : '';