This commit is contained in:
白雾三语 2025-06-27 20:01:23 +09:00 committed by GitHub
commit 1c5f69ecb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -872,6 +872,23 @@ describe('renderer: teleport', () => {
// children[0] is the start anchor
expect(tRefInMounted).toBe(target.children[1])
})
// 8146
test(`ensure correct rendering when target is empty`, async () => {
const root = nodeOps.createElement('div')
const App = {
setup() {
return () => h(Teleport, { to: null }, h('div', 'teleported'))
},
}
render(h(App), root)
await nextTick()
expect(serializeInner(root)).toMatchInlineSnapshot(
`"<!--teleport start--><div>teleported</div><!--teleport end-->"`,
)
expect(`Invalid Teleport target: null`).toHaveBeenWarnedTimes(1)
expect(`Invalid Teleport target on mount`).toHaveBeenWarnedTimes(1)
})
}
test('handle update and hmr rerender', async () => {

View File

@ -158,7 +158,7 @@ export const TeleportImpl = {
}
}
if (disabled) {
if (disabled || !target) {
mount(container, mainAnchor)
updateCssVars(n2, true)
}