Skip to content

Commit b03868c

Browse files
committed
Fixes sagalbot#671. The method isOptionSelected on options of type 'object' was cycling but no returning after an existing option was found (true), resetting to false on next option.
1 parent e0584cd commit b03868c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/components/Select.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,18 @@
904904
* @return {Boolean} True when selected | False otherwise
905905
*/
906906
isOptionSelected(option) {
907-
let selected = false
908-
this.valueAsArray.forEach(value => {
909-
if (typeof value === 'object') {
910-
selected = this.optionObjectComparator(value, option)
911-
} else if (value === option || value === option[this.index]) {
912-
selected = true
913-
}
914-
})
915-
return selected
907+
let selected = false
908+
let i = 0
909+
while (!selected && i < this.valueAsArray.length) {
910+
let value = this.valueAsArray[i]
911+
if (typeof value === 'object') {
912+
selected = this.optionObjectComparator(value, option)
913+
} else if (value === option || value === option[i]) {
914+
selected = true
915+
}
916+
i++
917+
}
918+
return selected
916919
},
917920
918921
/**

0 commit comments

Comments
 (0)