From b03868c449ae8325250e2f719f80bb37116c162d Mon Sep 17 00:00:00 2001 From: Cristian Totola Date: Thu, 25 Oct 2018 10:24:13 +0200 Subject: [PATCH] Fixes #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. --- src/components/Select.vue | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/Select.vue b/src/components/Select.vue index 4db3ba5..907d468 100644 --- a/src/components/Select.vue +++ b/src/components/Select.vue @@ -904,15 +904,18 @@ * @return {Boolean} True when selected | False otherwise */ isOptionSelected(option) { - let selected = false - this.valueAsArray.forEach(value => { - if (typeof value === 'object') { - selected = this.optionObjectComparator(value, option) - } else if (value === option || value === option[this.index]) { - selected = true - } - }) - return selected + let selected = false + let i = 0 + while (!selected && i < this.valueAsArray.length) { + let value = this.valueAsArray[i] + if (typeof value === 'object') { + selected = this.optionObjectComparator(value, option) + } else if (value === option || value === option[i]) { + selected = true + } + i++ + } + return selected }, /**