From: Carlos Rodrigues Date: Mon, 15 Jun 2020 13:31:14 +0000 (+0100) Subject: test(runtime-core): test multi-root ref assignment (#1374) X-Git-Tag: v3.0.0-beta.16~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e9789cef14e35a39a7931a975159cbf0ef3095a;p=thirdparty%2Fvuejs%2Fcore.git test(runtime-core): test multi-root ref assignment (#1374) --- diff --git a/packages/runtime-core/__tests__/apiTemplateRef.spec.ts b/packages/runtime-core/__tests__/apiTemplateRef.spec.ts index acf4f5b37f..20d074fa1f 100644 --- a/packages/runtime-core/__tests__/apiTemplateRef.spec.ts +++ b/packages/runtime-core/__tests__/apiTemplateRef.spec.ts @@ -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]) + }) })