Skip to content

Commit

Permalink
fix(hmr): fix HMR for nested non-SFC components (vuejs#4077)
Browse files Browse the repository at this point in the history
  • Loading branch information
turrsis authored and chrislone committed Feb 4, 2023
1 parent 5887106 commit 3788f99
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/runtime-core/src/componentProps.ts
Expand Up @@ -192,6 +192,13 @@ export function initProps(
instance.attrs = attrs
}

function isInHmrContext(instance: ComponentInternalInstance | null) {
while (instance) {
if (instance.type.__hmrId) return true
instance = instance.parent
}
}

export function updateProps(
instance: ComponentInternalInstance,
rawProps: Data | null,
Expand All @@ -211,11 +218,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__ && isInHmrContext(instance)) &&
(optimized || patchFlag > 0) &&
!(patchFlag & PatchFlags.FULL_PROPS)
) {
Expand Down

0 comments on commit 3788f99

Please sign in to comment.