🌐 AI搜索 & 代理 主页
Skip to content

Commit 9badfd0

Browse files
committed
Nested <optgroup>'s is invalid HTML...
1 parent 55be7df commit 9badfd0

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

src/components/form-select/form-select-option-group.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import Vue from '../../utils/vue'
2-
import { isArray } from '../../utils/inspect'
2+
import { htmlOrText } from '../../utils/html'
3+
import formOptionsMixin from '../../mixins/form-options'
34
import normalizeSlotMixin from '../../mixins/normalize-slot'
4-
import optionsMixin from './helpers/mixin-options'
55
import { BFormSelectOption } from './form-select-option'
66

77
// @vue/component
88
const BFormSelectOptionGroup = /*#__PURE__*/ Vue.extend({
99
name: 'BFormSelectOptionGroup',
10-
mixins: [normalizeSlotMixin, optionsMixin],
10+
mixins: [normalizeSlotMixin, formOptionsMixin],
1111
props: {
1212
label: {
1313
type: String,
@@ -17,17 +17,13 @@ const BFormSelectOptionGroup = /*#__PURE__*/ Vue.extend({
1717
render(h) {
1818
return h('optgroup', { attrs: { label: this.label } }, [
1919
this.normalizeSlot('first'),
20-
this.formOptions.map((option, index) => {
21-
const key = `option_${index}_opt`
22-
const options = option.options
23-
return isArray(options)
24-
? h(BFormSelectOptionGroup, { props: { label: option.label, options }, key })
25-
: h(
26-
BFormSelectOption,
27-
{ props: { value: option.value, disabled: option.disabled }, key },
28-
option.html || option.text
29-
)
30-
}),
20+
this.formOptions.map((option, index) =>
21+
h(BFormSelectOption, {
22+
props: { value: option.value, disabled: option.disabled },
23+
domProps: htmlOrText(option.html, option.text),
24+
key: `option_${index}_opt`
25+
})
26+
),
3127
this.normalizeSlot('default')
3228
])
3329
}

src/components/form-select/form-select.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Vue from '../../utils/vue'
22
import { from as arrayFrom, isArray } from '../../utils/array'
3+
import { htmlOrText } from '../../utils/html'
34
import idMixin from '../../mixins/id'
45
import formMixin from '../../mixins/form'
56
import formSizeMixin from '../../mixins/form-size'
@@ -133,11 +134,11 @@ export const BFormSelect = /*#__PURE__*/ Vue.extend({
133134
const options = option.options
134135
return isArray(options)
135136
? h(BFormSelectOptionGroup, { props: { label: option.label, options }, key })
136-
: h(
137-
BFormSelectOption,
138-
{ props: { value: option.value, disabled: option.disabled }, key },
139-
option.html || option.text
140-
)
137+
: h(BFormSelectOption, {
138+
props: { value: option.value, disabled: option.disabled },
139+
domProps: htmlOrText(option.html, option.text),
140+
key
141+
})
141142
}),
142143
this.normalizeSlot('default')
143144
]

src/components/form-select/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"slots": [
9090
{
9191
"name": "first",
92-
"description": "Slot to place options or option groups above options provided via the 'options' prop"
92+
"description": "Slot to place options above options provided via the 'options' prop"
9393
}
9494
]
9595
}

0 commit comments

Comments
 (0)