From b26976b6d8466e06cbb032bb26557db9a7b2303c Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 15 May 2020 17:05:26 -0400 Subject: [PATCH] wip: fix tests --- packages/runtime-core/src/hydration.ts | 7 ++++--- packages/server-renderer/__tests__/renderToString.spec.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/runtime-core/src/hydration.ts b/packages/runtime-core/src/hydration.ts index 5816b183..5d8fd41f 100644 --- a/packages/runtime-core/src/hydration.ts +++ b/packages/runtime-core/src/hydration.ts @@ -118,16 +118,17 @@ export function createHydrationFunctions( return onMismatch() } // determine anchor, adopt content - let content = '' 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++) { - content += (cur as Element).outerHTML + if (needToAdoptContent) vnode.children += (cur as Element).outerHTML if (i === vnode.staticCount - 1) { vnode.anchor = cur } cur = nextSibling(cur)! } - vnode.children = content return cur case Fragment: if (!isFragmentStart) { diff --git a/packages/server-renderer/__tests__/renderToString.spec.ts b/packages/server-renderer/__tests__/renderToString.spec.ts index ed58e2a3..b034312c 100644 --- a/packages/server-renderer/__tests__/renderToString.spec.ts +++ b/packages/server-renderer/__tests__/renderToString.spec.ts @@ -536,7 +536,7 @@ describe('ssr: renderToString', () => { test('Static', async () => { const content = `
helloworld
` - expect(await renderToString(createStaticVNode(content))).toBe(content) + expect(await renderToString(createStaticVNode(content, 1))).toBe(content) }) })