From bbfc8f92f31948121a79a108be086a2a98d2e093 Mon Sep 17 00:00:00 2001 From: underfin Date: Thu, 20 Aug 2020 15:09:52 +0800 Subject: [PATCH 1/2] fix(runtime-core): don't inherit `el` if child is block node fix #1903 --- packages/runtime-core/src/components/Teleport.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/runtime-core/src/components/Teleport.ts b/packages/runtime-core/src/components/Teleport.ts index ca885c3d920..9fa3d83ab32 100644 --- a/packages/runtime-core/src/components/Teleport.ts +++ b/packages/runtime-core/src/components/Teleport.ts @@ -146,6 +146,7 @@ export const TeleportImpl = { const oldChildren = n1.children as VNode[] const children = n2.children as VNode[] for (let i = 0; i < children.length; i++) { + if (n2.dynamicChildren.includes(children[i])) continue children[i].el = oldChildren[i].el } } From c0c48b961264defb65c64979a19628311c481011 Mon Sep 17 00:00:00 2001 From: underfin Date: Thu, 20 Aug 2020 15:18:30 +0800 Subject: [PATCH 2/2] test: add test --- packages/runtime-core/__tests__/components/Teleport.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/__tests__/components/Teleport.spec.ts b/packages/runtime-core/__tests__/components/Teleport.spec.ts index eaa6e227ee3..d8f07a45950 100644 --- a/packages/runtime-core/__tests__/components/Teleport.spec.ts +++ b/packages/runtime-core/__tests__/components/Teleport.spec.ts @@ -316,7 +316,7 @@ describe('renderer: teleport', () => { }, render: compile(` -
teleported
{{ disabled }} +
teleported
{{ disabled }}
root
`) @@ -326,7 +326,7 @@ describe('renderer: teleport', () => { `"
root
"` ) expect(serializeInner(target)).toMatchInlineSnapshot( - `"
teleported
false"` + `"
teleported
"` ) disabled.value = true @@ -343,7 +343,7 @@ describe('renderer: teleport', () => { `"
root
"` ) expect(serializeInner(target)).toMatchInlineSnapshot( - `"
teleported
false"` + `"
teleported
"` ) }) })