Skip to content

Commit

Permalink
test: test case for style binding w/ object value + v-show
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 authored and edison1105 committed Jan 11, 2024
1 parent 9fca15f commit 848ba55
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/runtime-dom/__tests__/directives/vShow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,32 @@ describe('runtime-dom: v-show directive', () => {
expect($div.style.display).toEqual('')
})

test('the value of `display` set by v-show should not be overwritten by the style attribute when updated (object value)', async () => {
const style = ref({
display: 'block',
width: '100px',
})
const display = ref(false)
const component = defineComponent({
render() {
return withVShow(h('div', { style: style.value }), display.value)
},
})
render(h(component), root)

const $div = root.children[0]

expect($div.style.display).toEqual('none')

style.value.width = '50px'
await nextTick()
expect($div.style.display).toEqual('none')

display.value = true
await nextTick()
expect($div.style.display).toEqual('block')
})

// #2583, #2757
test('the value of `display` set by v-show should not be overwritten by the style attribute when updated (with Transition)', async () => {
const style = ref('width: 100px')
Expand Down

0 comments on commit 848ba55

Please sign in to comment.