From f0b5f7ed8ddf74f9f5ba47cb65e8300370875291 Mon Sep 17 00:00:00 2001 From: yangxiuxiu <79584569+yangxiuxiu1115@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:38:41 +0800 Subject: [PATCH] fix(hydration): fix SFC style v-bind hydration mismatch warnings (#10250) close #10215 --- .../runtime-core/__tests__/hydration.spec.ts | 16 ++++++++++++++++ packages/runtime-core/src/component.ts | 6 ++++++ packages/runtime-core/src/hydration.ts | 12 +++++++++++- packages/runtime-dom/src/helpers/useCssVars.ts | 4 ++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/__tests__/hydration.spec.ts b/packages/runtime-core/__tests__/hydration.spec.ts index 127c0d88c7f..3fa0d7e732e 100644 --- a/packages/runtime-core/__tests__/hydration.spec.ts +++ b/packages/runtime-core/__tests__/hydration.spec.ts @@ -19,6 +19,7 @@ import { onMounted, ref, renderSlot, + useCssVars, vModelCheckbox, vShow, withDirectives, @@ -1538,5 +1539,20 @@ describe('SSR hydration', () => { ) expect(`Hydration attribute mismatch`).not.toHaveBeenWarned() }) + + test('should not warn css v-bind', () => { + const container = document.createElement('div') + container.innerHTML = `
` + const app = createSSRApp({ + setup() { + useCssVars(() => ({ + foo: 'red', + })) + return () => h('div', { style: { color: 'var(--foo)' } }) + }, + }) + app.mount(container) + expect(`Hydration style mismatch`).not.toHaveBeenWarned() + }) }) }) diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 1508627e579..ed1f8efee52 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -519,6 +519,12 @@ export interface ComponentInternalInstance { * @internal */ ut?: (vars?: Record