File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
packages/runtime-vapor/src Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,13 @@ export function createComponent(
172172 frag . hydrate ( )
173173 }
174174
175+ if ( __DEV__ ) {
176+ const instance = currentInstance as VaporComponentInstance
177+ ; ( instance ! . hmrEffects || ( instance ! . hmrEffects = [ ] ) ) . push ( ( ) =>
178+ frag . remove ( frag . anchor . parentNode ! ) ,
179+ )
180+ }
181+
175182 return frag as any
176183 }
177184
@@ -389,6 +396,7 @@ export class VaporComponentInstance implements GenericComponentInstance {
389396 devtoolsRawSetupState ?: any
390397 hmrRerender ?: ( ) => void
391398 hmrReload ?: ( newComp : VaporComponent ) => void
399+ hmrEffects ?: ( ( ) => void ) [ ]
392400 propsOptions ?: NormalizedPropsOptions
393401 emitsOptions ?: ObjectEmitsOptions | null
394402 isSingleRoot ?: boolean
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ export function hmrRerender(instance: VaporComponentInstance): void {
1919 const parent = normalized [ 0 ] . parentNode !
2020 const anchor = normalized [ normalized . length - 1 ] . nextSibling
2121 remove ( instance . block , parent )
22+ if ( instance . hmrEffects ) {
23+ instance . hmrEffects . forEach ( e => e ( ) )
24+ instance . hmrEffects . length = 0
25+ }
2226 const prev = currentInstance
2327 simpleSetCurrentInstance ( instance )
2428 pushWarningContext ( instance )
@@ -36,6 +40,10 @@ export function hmrReload(
3640 const parent = normalized [ 0 ] . parentNode !
3741 const anchor = normalized [ normalized . length - 1 ] . nextSibling
3842 unmountComponent ( instance , parent )
43+ if ( instance . hmrEffects ) {
44+ instance . hmrEffects . forEach ( e => e ( ) )
45+ instance . hmrEffects . length = 0
46+ }
3947 const prev = currentInstance
4048 simpleSetCurrentInstance ( instance . parent )
4149 const newInstance = createComponent (
You can’t perform that action at this time.
0 commit comments