Skip to content

Commit

Permalink
fix(hmr): properly force hmr full component which uses directives pro…
Browse files Browse the repository at this point in the history
…ps update
  • Loading branch information
turrsis committed Jul 7, 2021
1 parent 03e2684 commit ba5f984
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/runtime-core/src/componentProps.ts
Expand Up @@ -177,6 +177,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,
Expand All @@ -196,11 +209,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)
) {
Expand Down

0 comments on commit ba5f984

Please sign in to comment.