fix(hmr): fix HMR for nested non-SFC components (#4077)
This commit is contained in:
parent
0739f8909a
commit
96eb745254
@ -192,6 +192,13 @@ export function initProps(
|
|||||||
instance.attrs = attrs
|
instance.attrs = attrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isInHmrContext(instance: ComponentInternalInstance | null) {
|
||||||
|
while (instance) {
|
||||||
|
if (instance.type.__hmrId) return true
|
||||||
|
instance = instance.parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function updateProps(
|
export function updateProps(
|
||||||
instance: ComponentInternalInstance,
|
instance: ComponentInternalInstance,
|
||||||
rawProps: Data | null,
|
rawProps: Data | null,
|
||||||
@ -211,11 +218,7 @@ export function updateProps(
|
|||||||
// always force full diff in dev
|
// always force full diff in dev
|
||||||
// - #1942 if hmr is enabled with sfc component
|
// - #1942 if hmr is enabled with sfc component
|
||||||
// - vite#872 non-sfc component used by sfc component
|
// - vite#872 non-sfc component used by sfc component
|
||||||
!(
|
!(__DEV__ && isInHmrContext(instance)) &&
|
||||||
__DEV__ &&
|
|
||||||
(instance.type.__hmrId ||
|
|
||||||
(instance.parent && instance.parent.type.__hmrId))
|
|
||||||
) &&
|
|
||||||
(optimized || patchFlag > 0) &&
|
(optimized || patchFlag > 0) &&
|
||||||
!(patchFlag & PatchFlags.FULL_PROPS)
|
!(patchFlag & PatchFlags.FULL_PROPS)
|
||||||
) {
|
) {
|
||||||
|
Loading…
Reference in New Issue
Block a user