mirror of
https://github.com/element-plus/element-plus.git
synced 2025-03-19 16:00:34 +08:00
perf(select): select options watch flush post (#1513)
* perf(select): select options watch flush post fix #1512 * test(select): cover sync set value and options test Co-authored-by: liao-zhi-peng <liaozhipeng@weis-inc.com>
This commit is contained in:
parent
efc12c341d
commit
966b76e9d2
@ -210,6 +210,7 @@ describe('Carousel', () => {
|
||||
await nextTick()
|
||||
await wrapper.find('.el-carousel').trigger('mouseenter')
|
||||
const items = wrapper.vm.$el.querySelectorAll('.el-carousel__item')
|
||||
await nextTick()
|
||||
await wait(60)
|
||||
expect(items[1].classList.contains('is-active')).toBeTruthy()
|
||||
done()
|
||||
|
@ -164,6 +164,38 @@ describe('Select', () => {
|
||||
expect(wrapper.find('.el-input__inner').element.value).toBe('双皮奶')
|
||||
})
|
||||
|
||||
|
||||
test('sync set value and options', async () => {
|
||||
const wrapper = _mount(`
|
||||
<el-select v-model="value">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:label="item.label"
|
||||
:key="item.value"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
`,
|
||||
() => ({
|
||||
options: [{
|
||||
value: '选项1',
|
||||
label: '黄金糕',
|
||||
}, {
|
||||
value: '选项2',
|
||||
label: '双皮奶',
|
||||
}],
|
||||
value: '选项2',
|
||||
}))
|
||||
const vm = wrapper.vm as any
|
||||
vm.options = [{
|
||||
value: '选项1',
|
||||
label: '黄金糕',
|
||||
}]
|
||||
vm.value = '选项1'
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.find('.el-input__inner').element.value).toBe('黄金糕')
|
||||
})
|
||||
|
||||
test('single select', async () => {
|
||||
const wrapper = _mount(`
|
||||
<el-select v-model="value" @change="handleChange">
|
||||
|
@ -230,6 +230,9 @@ export const useSelect = (props, states: States, ctx) => {
|
||||
checkDefaultFirstOption()
|
||||
}
|
||||
},
|
||||
{
|
||||
flush: 'post',
|
||||
},
|
||||
)
|
||||
|
||||
watch(() => states.hoverIndex, val => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user