From f95b118edb70e99888e98e8ff475fea6f3c13405 Mon Sep 17 00:00:00 2001 From: Jeff Sagal Date: Sat, 2 Mar 2019 14:40:16 -0800 Subject: [PATCH] refactor deselect method (#768) --- src/components/Select.vue | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/components/Select.vue b/src/components/Select.vue index f56e66d..88c5a83 100644 --- a/src/components/Select.vue +++ b/src/components/Select.vue @@ -555,14 +555,9 @@ */ deselect(option) { if (this.multiple) { - let ref = -1 - this.mutableValue.forEach((val) => { - if (val === option || (this.index && val === option[this.index]) || (typeof val === 'object' && val[this.label] === option[this.label])) { - ref = val - } - }) - var index = this.mutableValue.indexOf(ref) - this.mutableValue.splice(index, 1) + this.mutableValue = this.mutableValue.filter(val => { + return ! (val === option || (this.index && val === option[this.index]) || (typeof val === 'object' && val[this.label] === option[this.label])); + }); } else { this.mutableValue = null }