Skip to content

Commit b26976b

Browse files
committed
wip: fix tests
1 parent dc229bc commit b26976b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/runtime-core/src/hydration.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,17 @@ export function createHydrationFunctions(
118118
return onMismatch()
119119
}
120120
// determine anchor, adopt content
121-
let content = ''
122121
let cur = node
122+
// if the static vnode has its content stripped during build,
123+
// adopt it from the server-rendered HTML.
124+
const needToAdoptContent = !(vnode.children as string).length
123125
for (let i = 0; i < vnode.staticCount; i++) {
124-
content += (cur as Element).outerHTML
126+
if (needToAdoptContent) vnode.children += (cur as Element).outerHTML
125127
if (i === vnode.staticCount - 1) {
126128
vnode.anchor = cur
127129
}
128130
cur = nextSibling(cur)!
129131
}
130-
vnode.children = content
131132
return cur
132133
case Fragment:
133134
if (!isFragmentStart) {

packages/server-renderer/__tests__/renderToString.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ describe('ssr: renderToString', () => {
536536

537537
test('Static', async () => {
538538
const content = `<div id="ok">hello<span>world</span></div>`
539-
expect(await renderToString(createStaticVNode(content))).toBe(content)
539+
expect(await renderToString(createStaticVNode(content, 1))).toBe(content)
540540
})
541541
})
542542

0 commit comments

Comments
 (0)