diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index c4ab05dd021..823ec64cac2 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -178,6 +178,19 @@ export function initProps( instance.attrs = attrs } +function inHmrContext(instance: ComponentInternalInstance) { + if (instance.type.__hmrId) { + return instance.type.__hmrId + } + let parent = instance.parent + while (parent) { + if (parent.type.__file) { + return parent.type.__hmrId + } + parent = parent.parent + } +} + export function updateProps( instance: ComponentInternalInstance, rawProps: Data | null, @@ -197,11 +210,7 @@ export function updateProps( // always force full diff in dev // - #1942 if hmr is enabled with sfc component // - vite#872 non-sfc component used by sfc component - !( - __DEV__ && - (instance.type.__hmrId || - (instance.parent && instance.parent.type.__hmrId)) - ) && + !(__DEV__ && inHmrContext(instance)) && (optimized || patchFlag > 0) && !(patchFlag & PatchFlags.FULL_PROPS) ) {