Skip to content

Commit f5722b1

Browse files
committed
Revert "fix: nested form options normalization"
This reverts commit bea0393.
1 parent bea0393 commit f5722b1

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/components/form-select/helpers/mixin-options.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import get from '../../../utils/get'
2-
import { isNull, isPlainObject, isUndefined } from '../../../utils/inspect'
2+
import { isArray, isPlainObject, isUndefined } from '../../../utils/inspect'
33
import formOptionsMixin from '../../../mixins/form-options'
44

55
// @vue/component
@@ -21,12 +21,12 @@ export default {
2121
if (isPlainObject(option)) {
2222
const value = get(option, this.valueField)
2323
const text = get(option, this.textField)
24-
const options = get(option, this.optionsField, null)
24+
const options = get(option, this.optionsField)
2525
// When it has options, create an `<optgroup>` object
26-
if (!isNull(options)) {
26+
if (isArray(options)) {
2727
return {
2828
label: String(get(option, this.labelField) || text),
29-
options: this.normalizeOptions(options)
29+
options
3030
}
3131
}
3232
// Otherwise create an `<option>` object

src/mixins/form-options.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@ export default {
3333
},
3434
computed: {
3535
formOptions() {
36-
return this.normalizeOptions(this.options)
36+
const options = this.options
37+
// Normalize the given options array
38+
if (isArray(options)) {
39+
return options.map(option => this.normalizeOption(option))
40+
} else if (isPlainObject(options)) {
41+
// Deprecate the object options format
42+
warn(OPTIONS_OBJECT_DEPRECATED_MSG, this.$options.name)
43+
// Normalize a `options` object to an array of options
44+
return keys(options).map(key => this.normalizeOption(options[key] || {}, key))
45+
}
46+
// If not an array or object, return an empty array
47+
/* istanbul ignore next */
48+
return []
3749
}
3850
},
3951
methods: {
@@ -55,20 +67,6 @@ export default {
5567
text: stripTags(String(option)),
5668
disabled: false
5769
}
58-
},
59-
normalizeOptions(options) {
60-
// Normalize the given options array
61-
if (isArray(options)) {
62-
return options.map(option => this.normalizeOption(option))
63-
} else if (isPlainObject(options)) {
64-
// Deprecate the object options format
65-
warn(OPTIONS_OBJECT_DEPRECATED_MSG, this.$options.name)
66-
// Normalize a `options` object to an array of options
67-
return keys(options).map(key => this.normalizeOption(options[key] || {}, key))
68-
}
69-
// If not an array or object, return an empty array
70-
/* istanbul ignore next */
71-
return []
7270
}
7371
}
7472
}

0 commit comments

Comments
 (0)