File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -548,7 +548,7 @@ export interface GenericComponentInstance {
548548 /**
549549 * @internal vapor only
550550 */
551- hmrRerender ?: ( ) => void
551+ hmrRerender ?: ( dirtyInstance ?: any ) => void
552552 /**
553553 * @internal vapor only
554554 */
Original file line number Diff line number Diff line change @@ -172,9 +172,7 @@ function reload(id: string, newComp: HMRComponent): void {
172172 isHmrUpdating = true
173173 const parent = instance . parent ! as ComponentInternalInstance
174174 if ( parent . vapor ) {
175- // ensure unregisterHMR is called to avoid stale instances
176- instance . scope . stop ( )
177- parent . hmrRerender ! ( )
175+ parent . hmrRerender ! ( instance )
178176 } else {
179177 if ( ! ( parent . effect . flags ! & EffectFlags . STOP ) ) {
180178 parent . renderCache = [ ]
Original file line number Diff line number Diff line change @@ -15,10 +15,16 @@ import {
1515} from './component'
1616import { isArray } from '@vue/shared'
1717
18- export function hmrRerender ( instance : VaporComponentInstance ) : void {
18+ export function hmrRerender (
19+ instance : VaporComponentInstance ,
20+ dirtyInstance ?: VaporComponentInstance ,
21+ ) : void {
1922 const normalized = normalizeBlock ( instance . block )
2023 const parent = normalized [ 0 ] . parentNode !
2124 const anchor = normalized [ normalized . length - 1 ] . nextSibling
25+ // When dirty instance is provided, instance is its parent component
26+ // and dirty instance needs to be unmount to ensure unregister HMR
27+ if ( dirtyInstance ) unmountComponent ( dirtyInstance )
2228 remove ( instance . block , parent )
2329 const prev = setCurrentInstance ( instance )
2430 if ( instance . renderEffects ) {
@@ -38,8 +44,7 @@ export function hmrReload(
3844) : void {
3945 // if parent is KeepAlive, we need to rerender it
4046 if ( instance . parent && isKeepAlive ( instance . parent ) ) {
41- instance . scope . stop ( )
42- instance . parent . hmrRerender ! ( )
47+ instance . parent . hmrRerender ! ( instance )
4348 return
4449 }
4550 const normalized = normalizeBlock ( instance . block )
You can’t perform that action at this time.
0 commit comments