Skip to content

Commit f95b118

Browse files
authored
refactor deselect method (sagalbot#768)
1 parent dc91310 commit f95b118

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/components/Select.vue

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,14 +555,9 @@
555555
*/
556556
deselect(option) {
557557
if (this.multiple) {
558-
let ref = -1
559-
this.mutableValue.forEach((val) => {
560-
if (val === option || (this.index && val === option[this.index]) || (typeof val === 'object' && val[this.label] === option[this.label])) {
561-
ref = val
562-
}
563-
})
564-
var index = this.mutableValue.indexOf(ref)
565-
this.mutableValue.splice(index, 1)
558+
this.mutableValue = this.mutableValue.filter(val => {
559+
return ! (val === option || (this.index && val === option[this.index]) || (typeof val === 'object' && val[this.label] === option[this.label]));
560+
});
566561
} else {
567562
this.mutableValue = null
568563
}

0 commit comments

Comments
 (0)