]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: test case for style binding w/ object value + v-show
authorEvan You <yyx990803@gmail.com>
Thu, 11 Jan 2024 09:14:49 +0000 (17:14 +0800)
committerEvan You <yyx990803@gmail.com>
Thu, 11 Jan 2024 09:14:49 +0000 (17:14 +0800)
ref #10074

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

index 5e837650854788e5d936f1f1452c8caa524dbdc5..70b69f2df1c10050e3c42547a49d78511739752a 100644 (file)
@@ -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')