wip: fix tests
This commit is contained in:
parent
dc229bcda4
commit
b26976b6d8
@ -118,16 +118,17 @@ export function createHydrationFunctions(
|
|||||||
return onMismatch()
|
return onMismatch()
|
||||||
}
|
}
|
||||||
// determine anchor, adopt content
|
// determine anchor, adopt content
|
||||||
let content = ''
|
|
||||||
let cur = node
|
let cur = node
|
||||||
|
// if the static vnode has its content stripped during build,
|
||||||
|
// adopt it from the server-rendered HTML.
|
||||||
|
const needToAdoptContent = !(vnode.children as string).length
|
||||||
for (let i = 0; i < vnode.staticCount; i++) {
|
for (let i = 0; i < vnode.staticCount; i++) {
|
||||||
content += (cur as Element).outerHTML
|
if (needToAdoptContent) vnode.children += (cur as Element).outerHTML
|
||||||
if (i === vnode.staticCount - 1) {
|
if (i === vnode.staticCount - 1) {
|
||||||
vnode.anchor = cur
|
vnode.anchor = cur
|
||||||
}
|
}
|
||||||
cur = nextSibling(cur)!
|
cur = nextSibling(cur)!
|
||||||
}
|
}
|
||||||
vnode.children = content
|
|
||||||
return cur
|
return cur
|
||||||
case Fragment:
|
case Fragment:
|
||||||
if (!isFragmentStart) {
|
if (!isFragmentStart) {
|
||||||
|
@ -536,7 +536,7 @@ describe('ssr: renderToString', () => {
|
|||||||
|
|
||||||
test('Static', async () => {
|
test('Static', async () => {
|
||||||
const content = `<div id="ok">hello<span>world</span></div>`
|
const content = `<div id="ok">hello<span>world</span></div>`
|
||||||
expect(await renderToString(createStaticVNode(content))).toBe(content)
|
expect(await renderToString(createStaticVNode(content, 1))).toBe(content)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user