fix(ssr): fix unintended error on Teleport
hydration mismatch (#1271)
fix #1235
This commit is contained in:
parent
d863ce721f
commit
c463a71bb3
@ -37,6 +37,10 @@ const triggerEvent = (type: string, el: Element) => {
|
||||
describe('SSR hydration', () => {
|
||||
mockWarn()
|
||||
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
test('text', async () => {
|
||||
const msg = ref('foo')
|
||||
const { vnode, container } = mountWithHydration('foo', () => msg.value)
|
||||
@ -686,5 +690,17 @@ describe('SSR hydration', () => {
|
||||
// excessive children removal
|
||||
expect(`Hydration children mismatch`).toHaveBeenWarned()
|
||||
})
|
||||
|
||||
test('Teleport target has empty children', () => {
|
||||
const teleportContainer = document.createElement('div')
|
||||
teleportContainer.id = 'teleport'
|
||||
document.body.appendChild(teleportContainer)
|
||||
|
||||
mountWithHydration('<!--teleport start--><!--teleport end-->', () =>
|
||||
h(Teleport, { to: '#teleport' }, [h('span', 'value')])
|
||||
)
|
||||
expect(teleportContainer.innerHTML).toBe(`<span>value</span>`)
|
||||
expect(`Hydration children mismatch`).toHaveBeenWarned()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -314,9 +314,8 @@ function hydrateTeleport(
|
||||
optimized
|
||||
)
|
||||
}
|
||||
;(target as TeleportTargetElement)._lpa = nextSibling(
|
||||
vnode.targetAnchor as Node
|
||||
)
|
||||
;(target as TeleportTargetElement)._lpa =
|
||||
vnode.targetAnchor && nextSibling(vnode.targetAnchor as Node)
|
||||
}
|
||||
}
|
||||
return vnode.anchor && nextSibling(vnode.anchor as Node)
|
||||
|
Loading…
Reference in New Issue
Block a user