diff --git a/packages/runtime-core/__tests__/components/Teleport.spec.ts b/packages/runtime-core/__tests__/components/Teleport.spec.ts
index eaa6e227ee3..44a08c6687f 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,13 +326,13 @@ describe('renderer: teleport', () => {
`"root
"`
)
expect(serializeInner(target)).toMatchInlineSnapshot(
- `"teleported
false"`
+ `"teleported
false"`
)
disabled.value = true
await nextTick()
expect(serializeInner(root)).toMatchInlineSnapshot(
- `"teleported
trueroot
"`
+ `"teleported
trueroot
"`
)
expect(serializeInner(target)).toBe(``)
@@ -343,7 +343,7 @@ describe('renderer: teleport', () => {
`"root
"`
)
expect(serializeInner(target)).toMatchInlineSnapshot(
- `"teleported
false"`
+ `"teleported
false"`
)
})
})
diff --git a/packages/runtime-core/src/components/Teleport.ts b/packages/runtime-core/src/components/Teleport.ts
index ca885c3d920..1d6a996de0e 100644
--- a/packages/runtime-core/src/components/Teleport.ts
+++ b/packages/runtime-core/src/components/Teleport.ts
@@ -146,7 +146,10 @@ export const TeleportImpl = {
const oldChildren = n1.children as VNode[]
const children = n2.children as VNode[]
for (let i = 0; i < children.length; i++) {
- children[i].el = oldChildren[i].el
+ // only inherit for non-patched nodes (i.e. static ones)
+ if (!children[i].el) {
+ children[i].el = oldChildren[i].el
+ }
}
}
} else if (!optimized) {