mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-18 10:59:10 +08:00
fix(components): [time-picker] am/pm mode avoid render redundant content (#4137)
fix #4020
This commit is contained in:
parent
d6abd9fee1
commit
f7a553184c
@ -592,4 +592,43 @@ describe('TimePicker(range)', () => {
|
||||
ElPopperOptions
|
||||
)
|
||||
})
|
||||
|
||||
it('am/pm mode avoid render redundant content', async () => {
|
||||
const wrapper = _mount(
|
||||
`<el-time-picker
|
||||
v-model="timeRange"
|
||||
is-range
|
||||
range-separator="To"
|
||||
start-placeholder="Start time"
|
||||
end-placeholder="End time"
|
||||
arrow-control
|
||||
format="hh:mm:ss a"
|
||||
>
|
||||
</el-time-picker>
|
||||
`,
|
||||
() => ({
|
||||
timeRange: [],
|
||||
})
|
||||
)
|
||||
const input = wrapper.find('input')
|
||||
input.trigger('blur')
|
||||
input.trigger('focus')
|
||||
await nextTick()
|
||||
const list = document.querySelectorAll('.el-time-spinner__list')
|
||||
expect(
|
||||
list[0]
|
||||
.querySelector('.el-time-spinner__item.active')
|
||||
.innerHTML.split(' ').length
|
||||
).toBe(2)
|
||||
expect(
|
||||
list[1]
|
||||
.querySelector('.el-time-spinner__item.active')
|
||||
.innerHTML.split(' ').length
|
||||
).toBe(1)
|
||||
expect(
|
||||
list[2]
|
||||
.querySelector('.el-time-spinner__item.active')
|
||||
.innerHTML.split(' ').length
|
||||
).toBe(1)
|
||||
})
|
||||
})
|
||||
|
@ -59,12 +59,15 @@
|
||||
disabled: listMap[item].value[time],
|
||||
}"
|
||||
>
|
||||
{{
|
||||
time === undefined
|
||||
? ''
|
||||
: ('0' + (amPmMode ? time % 12 || 12 : time)).slice(-2) +
|
||||
getAmPmFlag(time)
|
||||
}}
|
||||
<template v-if="time">
|
||||
<template v-if="item === 'hours'">
|
||||
{{ ('0' + (amPmMode ? time % 12 || 12 : time)).slice(-2)
|
||||
}}{{ getAmPmFlag(time) }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ ('0' + time).slice(-2) }}
|
||||
</template>
|
||||
</template>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user