Skip to content

Commit ba5f984

Browse files
committed
fix(hmr): properly force hmr full component which uses directives props update
1 parent 03e2684 commit ba5f984

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/runtime-core/src/componentProps.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ export function initProps(
177177
instance.attrs = attrs
178178
}
179179

180+
function inHmrContext(instance: ComponentInternalInstance) {
181+
if (instance.type.__hmrId) {
182+
return instance.type.__hmrId
183+
}
184+
let parent = instance.parent
185+
while (parent) {
186+
if (parent.type.__file) {
187+
return parent.type.__hmrId
188+
}
189+
parent = parent.parent
190+
}
191+
}
192+
180193
export function updateProps(
181194
instance: ComponentInternalInstance,
182195
rawProps: Data | null,
@@ -196,11 +209,7 @@ export function updateProps(
196209
// always force full diff in dev
197210
// - #1942 if hmr is enabled with sfc component
198211
// - vite#872 non-sfc component used by sfc component
199-
!(
200-
__DEV__ &&
201-
(instance.type.__hmrId ||
202-
(instance.parent && instance.parent.type.__hmrId))
203-
) &&
212+
!(__DEV__ && inHmrContext(instance)) &&
204213
(optimized || patchFlag > 0) &&
205214
!(patchFlag & PatchFlags.FULL_PROPS)
206215
) {

0 commit comments

Comments
 (0)