Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMR doesn't update component which uses directives #4077

Merged
merged 2 commits into from Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/runtime-core/src/componentProps.ts
Expand Up @@ -178,6 +178,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 @@ -197,11 +204,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