Skip to content

Commit d8635e7

Browse files
eriknygrensagalbot
authored andcommitted
multiple mode - add/remove support vuex strictmode (sagalbot#702)
What --- - In multiple mode: Update adding or removing a value to use spread operator or filter, instead of mutating the array directly. Why --- So vuex strict mode doesn't throw warnings.
1 parent 182e11b commit d8635e7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/components/Select.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@
844844
if (this.multiple && !this.mutableValue) {
845845
this.mutableValue = [option]
846846
} else if (this.multiple) {
847-
this.mutableValue.push(option)
847+
this.mutableValue = [...this.mutableValue, option]
848848
} else {
849849
this.mutableValue = option
850850
}
@@ -867,8 +867,7 @@
867867
ref = val
868868
}
869869
})
870-
var index = this.mutableValue.indexOf(ref)
871-
this.mutableValue.splice(index, 1)
870+
this.mutableValue = this.mutableValue.filter(entry => entry !== ref)
872871
} else {
873872
this.mutableValue = null
874873
}

0 commit comments

Comments
 (0)