From f6974f6d61df8845385e7a82c831d1d75572cc39 Mon Sep 17 00:00:00 2001 From: stasson Date: Sun, 25 Feb 2018 23:01:57 +0100 Subject: [PATCH] revert(select): allow Number and Object value types This reverts commit 6a031dd52cac1f37e0ecc269009b2241546eb3f2. --- components/select/README.md | 12 ++++++------ components/select/demo.vue | 12 ++++++------ components/select/mdc-menu-option.vue | 10 +++------- components/select/mdc-menu-select.vue | 7 ++++--- components/select/mdc-multi-option.vue | 2 +- components/select/mdc-multi-select.vue | 2 +- components/select/mdc-native-option.vue | 2 +- components/select/mdc-native-select.vue | 2 +- components/select/mdc-option.vue | 2 +- components/select/mdc-select.vue | 2 +- 10 files changed, 25 insertions(+), 28 deletions(-) diff --git a/components/select/README.md b/components/select/README.md index eb94cd1b..3b873109 100644 --- a/components/select/README.md +++ b/components/select/README.md @@ -28,12 +28,12 @@ var vm = new Vue({ | props | Type | Default | Description | | ---------- | --------------- | ------- | -------------------------------------------- | | `disabled` | Boolean | false | whether this select is disabled | -| `label` | String | undefined | the selection label | -| `value` | [Number, String, Object, Array] | | bind with v-model (update on `change` event) | -| `multiple` | Boolean | false | whether the select accept multiple values | +| `label` | String | | the selection label | +| `value` | [String, Array] | | bind with v-model (update on `change` event) | +| `multiple` | Boolean | | whether the select accept multiple values | | `max-size` | Boolean | 4 | multi select max size | -| `native` | String | false | force native select rendering | -| `name` | String | undefined | native select name | +| `native` | String | | force native select rendering | +| `name` | String | | native select name | | event | Description | | -------- | ----------------------- | @@ -45,7 +45,7 @@ var vm = new Vue({ | props | Type | Default | Description | | ---------- | ------- | ------- | ------------------------------- | | `disabled` | Boolean | false | whether this option is disabled | -| `value` | [Number, String, Object] | text content | option value | +| `value` | String | | option value | > If no option value is specified, the select component will take the option's textContent. diff --git a/components/select/demo.vue b/components/select/demo.vue index c4e3ba02..1bf4b1bc 100644 --- a/components/select/demo.vue +++ b/components/select/demo.vue @@ -8,9 +8,9 @@


- *{{option}}* + {{option}} - + {{option}} @@ -40,7 +40,7 @@ food: { 'Vegetables' : ['Spinach', 'Carrots', 'Onions', 'Broccoli'], 'Meat' : [ 'Eggs', 'Chicken', 'Fish', 'Turkey', 'Pork' , 'Beef'], - 'Fruits' : [1, 2, {tutu: 3}, 'Berries', 'Lemons'], + 'Fruits' : ['Apples', 'Oranges', 'Bananas', 'Berries', 'Lemons'], } } }, diff --git a/components/select/mdc-menu-option.vue b/components/select/mdc-menu-option.vue index 3d0c7d5e..454f26d2 100644 --- a/components/select/mdc-menu-option.vue +++ b/components/select/mdc-menu-option.vue @@ -2,7 +2,8 @@
  • + :aria-disabled="disabled" + :data-value="value">
  • @@ -11,13 +12,8 @@ export default { name: 'mdc-menu-option', props: { - value: [Number, String, Object], + value: String, disabled: Boolean - }, - methods: { - getValue () { - return this.value || this.$el.textContent.trim() - } } } diff --git a/components/select/mdc-menu-select.vue b/components/select/mdc-menu-select.vue index 229f9d90..d1c98085 100644 --- a/components/select/mdc-menu-select.vue +++ b/components/select/mdc-menu-select.vue @@ -33,7 +33,7 @@ export default { }, props: { multiple: Boolean, - value: [Number, String, Object], + value: [String, Array], disabled: Boolean, label: String, box: Boolean @@ -69,7 +69,7 @@ export default { if (this.foundation) { let options = this.$refs.menu.items for (let i = 0; i < options.length; i++) { - let optionValue = options[i].__vue__.getValue() + let optionValue = options[i].getAttribute('data-value') || options[i].textContent.trim() if (this.value == optionValue) { this.foundation.setSelectedIndex(i) //TODO: MDCFIX force float above if value is valid @@ -151,7 +151,8 @@ export default { getTextForOptionAtIndex: (index) => this.$refs.menu.items[index].textContent.trim(), getValueForOptionAtIndex: (index) => { - return this.$refs.menu.items[index].__vue__.getValue() + return this.$refs.menu.items[index].getAttribute('data-value') + || this.$refs.menu.items[index].textContent.trim() }, setAttrForOptionAtIndex: (index, attr, value) => this.$refs.menu.items[index].setAttribute(attr, value), diff --git a/components/select/mdc-multi-option.vue b/components/select/mdc-multi-option.vue index 38534321..6bdadfc0 100644 --- a/components/select/mdc-multi-option.vue +++ b/components/select/mdc-multi-option.vue @@ -13,7 +13,7 @@ export default { name: 'mdc-multi-option', props: { - value: [Number, String, Object], + value: String, disabled: Boolean }, computed: { diff --git a/components/select/mdc-multi-select.vue b/components/select/mdc-multi-select.vue index 5121ef74..86ac000e 100644 --- a/components/select/mdc-multi-select.vue +++ b/components/select/mdc-multi-select.vue @@ -20,7 +20,7 @@ export default { }, props: { multiple: Boolean, - value: [Number, String, Object, Array], + value: [String, Array], disabled: Boolean, label: String, maxSize: { diff --git a/components/select/mdc-native-option.vue b/components/select/mdc-native-option.vue index e5bf2d00..e6b2b73f 100644 --- a/components/select/mdc-native-option.vue +++ b/components/select/mdc-native-option.vue @@ -13,7 +13,7 @@ export default { name: 'mdc-native-option', props: { - value: [Number, String, Object], + value: String, disabled: Boolean }, computed: { diff --git a/components/select/mdc-native-select.vue b/components/select/mdc-native-select.vue index 1d7fd0d3..6b11762d 100644 --- a/components/select/mdc-native-select.vue +++ b/components/select/mdc-native-select.vue @@ -16,7 +16,7 @@ export default { event: 'change' }, props: { - value: [Number, String], + value: [String, Array], disabled: Boolean, label: String }, diff --git a/components/select/mdc-option.vue b/components/select/mdc-option.vue index 21b9dee0..cbc11e3e 100644 --- a/components/select/mdc-option.vue +++ b/components/select/mdc-option.vue @@ -12,7 +12,7 @@ import MDCMultiOption from './mdc-multi-option.vue' export default { name: 'mdc-option', props: { - value: [Number, String, Object], + value: String, disabled: Boolean }, inject: ['mdcSelect'], diff --git a/components/select/mdc-select.vue b/components/select/mdc-select.vue index 3bba628a..d3c5e6a4 100644 --- a/components/select/mdc-select.vue +++ b/components/select/mdc-select.vue @@ -30,7 +30,7 @@ export default { }, props: { multiple: Boolean, - value: [Number, String, Object, Array], + value: [String, Array], label: String, native: Boolean },