]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: add tests edison/fix/12749 12756/head
authordaiwei <daiwei521@126.com>
Tue, 21 Jan 2025 02:57:07 +0000 (10:57 +0800)
committerdaiwei <daiwei521@126.com>
Tue, 21 Jan 2025 02:57:07 +0000 (10:57 +0800)
packages/runtime-core/__tests__/helpers/useTemplateRef.spec.ts

index adc8ed66c7789c76a14462ea8ddef2f766fa660f..047df6b492b687dc83218f1e5ab486ba0c08a7a4 100644 (file)
@@ -3,6 +3,7 @@ import {
   h,
   nextTick,
   nodeOps,
+  onMounted,
   ref,
   render,
   useTemplateRef,
@@ -125,4 +126,25 @@ describe('useTemplateRef', () => {
       __DEV__ = true
     }
   })
+
+  // #12749
+  test(`don't update setup ref for useTemplateRef key`, () => {
+    let foo: ShallowRef
+    const Comp = {
+      setup() {
+        foo = useTemplateRef('bar')
+        const bar = ref(null)
+        onMounted(() => {
+          expect(bar.value).toBe(null)
+        })
+        return { bar }
+      },
+      render() {
+        return h('div', { ref: 'bar' })
+      },
+    }
+    const root = nodeOps.createElement('div')
+    render(h(Comp), root)
+    expect(foo!.value).toBe(root.children[0])
+  })
 })