Skip to content

Commit 39cd6f3

Browse files
committed
check initial value for multiple selects #245
1 parent 29f84e1 commit 39cd6f3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/mdSelect/mdOption.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@
5050
}
5151
},
5252
methods: {
53+
isMultiple() {
54+
return this.parentSelect.multiple;
55+
},
5356
setParentOption() {
54-
if (!this.parentSelect.multiple) {
57+
if (!this.isMultiple()) {
5558
this.parentSelect.selectOption(this.value, this.$refs.item.textContent);
5659
} else {
5760
this.check = !this.check;
@@ -64,7 +67,7 @@
6467
},
6568
watch: {
6669
isSelected(selected) {
67-
if (this.parentSelect.multiple) {
70+
if (this.isMultiple()) {
6871
this.check = selected;
6972
}
7073
},
@@ -90,7 +93,7 @@
9093
this.parentSelect.multipleOptions[this.index] = {};
9194
this.parentSelect.options[this.index] = this;
9295
93-
if (this.parentSelect.value === this.value) {
96+
if (this.isMultiple() && this.parentSelect.value.indexOf(this.value) >= 0 || this.parentSelect.value === this.value) {
9497
this.setParentOption();
9598
}
9699
},

0 commit comments

Comments
 (0)