From f41fd86d5f26bd0009b4ca285ddc3cefaafa9f7c Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 12 Dec 2023 20:05:37 +0800 Subject: [PATCH] fix(hydration): swap client/server labels for hydration mismatch warnings this was swapped in #9098 but lost when merging #5953 --- packages/runtime-core/src/hydration.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/runtime-core/src/hydration.ts b/packages/runtime-core/src/hydration.ts index 106948a1278..c3fba6cc486 100644 --- a/packages/runtime-core/src/hydration.ts +++ b/packages/runtime-core/src/hydration.ts @@ -173,10 +173,10 @@ export function createHydrationFunctions( warn( `Hydration text mismatch in`, node.parentNode, - `\n - rendered on server: ${JSON.stringify(vnode.children)}` + - `\n - expected on client: ${JSON.stringify( - (node as Text).data - )}` + `\n - rendered on server: ${JSON.stringify( + (node as Text).data + )}` + + `\n - expected on client: ${JSON.stringify(vnode.children)}` ) ;(node as Text).data = vnode.children as string } @@ -431,8 +431,8 @@ export function createHydrationFunctions( warn( `Hydration text content mismatch on`, el, - `\n - rendered on server: ${vnode.children as string}` + - `\n - expected on client: ${el.textContent}` + `\n - rendered on server: ${el.textContent}` + + `\n - expected on client: ${vnode.children as string}` ) el.textContent = vnode.children as string } @@ -613,15 +613,15 @@ export function createHydrationFunctions( hasMismatch = true ;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn( - `Hydration node mismatch:\n- Client vnode:`, - vnode.type, - `\n- Server rendered DOM:`, + `Hydration node mismatch:\n- rendered on server:`, node, node.nodeType === DOMNodeTypes.TEXT ? `(text)` : isComment(node) && node.data === '[' ? `(start of fragment)` - : `` + : ``, + `\n- expected on client:`, + vnode.type ) vnode.el = null