Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/runtime-dom/__tests__/directives/vShow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,25 @@ describe('runtime-dom: v-show directive', () => {
expect($div.style.display).toEqual('block')
})

test('the value of `display` set by v-show should not be overwritten display', async () => {
const style = ref()
const display = ref(true)
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('')

style.value = { display: 'inline-block' }
await nextTick()
expect($div.style.display).toEqual('inline-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
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/modules/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
// so we always keep the current `display` value regardless of the `style`
// value, thus handing over control to `v-show`.
if (vShowOldKey in el) {
style.display = currentDisplay
style.display = currentDisplay || style.display
}
}

Expand Down