]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(runtime-core): test multi-root ref assignment (#1374)
authorCarlos Rodrigues <david-181@hotmail.com>
Mon, 15 Jun 2020 13:31:14 +0000 (14:31 +0100)
committerGitHub <noreply@github.com>
Mon, 15 Jun 2020 13:31:14 +0000 (09:31 -0400)
packages/runtime-core/__tests__/apiTemplateRef.spec.ts

index acf4f5b37f06bb4260714c5cb2c74b1445c75458..20d074fa1f97efb05fe1d696871d9a0407f55ef9 100644 (file)
@@ -218,4 +218,32 @@ describe('api: template refs', () => {
     render(h(Comp), root)
     expect(state.refKey).toBe(root.children[0])
   })
+
+  test('multiple root refs', () => {
+    const root = nodeOps.createElement('div')
+    const refKey1 = ref(null)
+    const refKey2 = ref(null)
+    const refKey3 = ref(null)
+
+    const Comp = {
+      setup() {
+        return {
+          refKey1,
+          refKey2,
+          refKey3
+        }
+      },
+      render() {
+        return [
+          h('div', { ref: 'refKey1' }),
+          h('div', { ref: 'refKey2' }),
+          h('div', { ref: 'refKey3' })
+        ]
+      }
+    }
+    render(h(Comp), root)
+    expect(refKey1.value).toBe(root.children[1])
+    expect(refKey2.value).toBe(root.children[2])
+    expect(refKey3.value).toBe(root.children[3])
+  })
 })