From: Evan You Date: Thu, 18 Jul 2024 13:15:27 +0000 (+0800) Subject: test(teleport): test for accessing template ref inside teleport in mounted X-Git-Tag: v3.5.0-alpha.3~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c03ab22249adea54a7214ed39d7918665ed395b;p=thirdparty%2Fvuejs%2Fcore.git test(teleport): test for accessing template ref inside teleport in mounted --- diff --git a/packages/runtime-core/__tests__/components/Teleport.spec.ts b/packages/runtime-core/__tests__/components/Teleport.spec.ts index 24400f6ed4..d2532a6db7 100644 --- a/packages/runtime-core/__tests__/components/Teleport.spec.ts +++ b/packages/runtime-core/__tests__/components/Teleport.spec.ts @@ -59,7 +59,7 @@ describe('renderer: teleport', () => {
-
teleported
+
teleported
@@ -705,5 +705,27 @@ describe('renderer: teleport', () => { await nextTick() expect(root.innerHTML).toMatchInlineSnapshot('""') }) + + test('accessing template refs inside teleport', async () => { + const target = nodeOps.createElement('div') + const tRef = ref() + let tRefInMounted + + render( + h({ + render: () => [ + h(Teleport, { to: target }, h('div', { ref: tRef }, 'teleported')), + h('div', 'root'), + ], + mounted() { + tRefInMounted = tRef.value + }, + }), + nodeOps.createElement('div'), + ) + + // children[0] is the start anchor + expect(tRefInMounted).toBe(target.children[1]) + }) } })