Skip to content

Commit 848ba55

Browse files
yyx990803edison1105
authored andcommitted
test: test case for style binding w/ object value + v-show
ref vuejs#10074
1 parent 9fca15f commit 848ba55

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/runtime-dom/__tests__/directives/vShow.spec.ts

+26
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,32 @@ describe('runtime-dom: v-show directive', () => {
151151
expect($div.style.display).toEqual('')
152152
})
153153

154+
test('the value of `display` set by v-show should not be overwritten by the style attribute when updated (object value)', async () => {
155+
const style = ref({
156+
display: 'block',
157+
width: '100px',
158+
})
159+
const display = ref(false)
160+
const component = defineComponent({
161+
render() {
162+
return withVShow(h('div', { style: style.value }), display.value)
163+
},
164+
})
165+
render(h(component), root)
166+
167+
const $div = root.children[0]
168+
169+
expect($div.style.display).toEqual('none')
170+
171+
style.value.width = '50px'
172+
await nextTick()
173+
expect($div.style.display).toEqual('none')
174+
175+
display.value = true
176+
await nextTick()
177+
expect($div.style.display).toEqual('block')
178+
})
179+
154180
// #2583, #2757
155181
test('the value of `display` set by v-show should not be overwritten by the style attribute when updated (with Transition)', async () => {
156182
const style = ref('width: 100px')

0 commit comments

Comments
 (0)