From 0c1efde83369aeebe1bf7805312b217fc43d0b72 Mon Sep 17 00:00:00 2001 From: underfin Date: Mon, 12 Oct 2020 14:47:30 +0800 Subject: [PATCH 1/2] fix(hmr): full diff props for non-sfc component close #https://github.com/vitejs/vite/issues/872 --- packages/runtime-core/src/componentProps.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 9fc2ac78b88..40a4a31494d 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -156,8 +156,10 @@ export function updateProps( const [options] = instance.propsOptions if ( - // always force full diff if hmr is enabled - !(__DEV__ && instance.type.__hmrId) && + // always force full diff in dev + // - #1942 if hmr is enabled with sfc component + // - vite#872 non-sfc component + !__DEV__ && (optimized || patchFlag > 0) && !(patchFlag & PatchFlags.FULL_PROPS) ) { From 6db61b009331e635b265e79b218505ae53a7aa95 Mon Sep 17 00:00:00 2001 From: underfin Date: Wed, 14 Oct 2020 09:51:52 +0800 Subject: [PATCH 2/2] refactor: update condition --- packages/runtime-core/src/componentProps.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 40a4a31494d..938318d4a9f 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -158,8 +158,12 @@ export function updateProps( if ( // always force full diff in dev // - #1942 if hmr is enabled with sfc component - // - vite#872 non-sfc component - !__DEV__ && + // - vite#872 non-sfc component used by sfc component + !( + __DEV__ && + (instance.type.__hmrId || + (instance.parent && instance.parent.type.__hmrId)) + ) && (optimized || patchFlag > 0) && !(patchFlag & PatchFlags.FULL_PROPS) ) {