@@ -13,12 +13,13 @@ import {
13
13
unmountComponent ,
14
14
} from './component'
15
15
import { isArray } from '@vue/shared'
16
+
16
17
export function hmrRerender ( instance : VaporComponentInstance ) : void {
17
18
const normalized = normalizeBlock ( instance . block )
18
19
const parent = normalized [ 0 ] . parentNode !
19
20
const anchor = normalized [ normalized . length - 1 ] . nextSibling
20
21
remove ( instance . block , parent )
21
- instance . scope ! . cleanup ( )
22
+ instance . scope . cleanup ( )
22
23
const prev = setCurrentInstance ( instance )
23
24
pushWarningContext ( instance )
24
25
devRender ( instance )
@@ -46,9 +47,20 @@ export function hmrReload(
46
47
setCurrentInstance ( ...prev )
47
48
mountComponent ( newInstance , parent , anchor )
48
49
49
- // update parentInstance.block to ensure that the correct parent and
50
- // anchor are found during parentInstance HMR rerender/reload, as
51
- // `normalizeBlock` relies on the current instance.block
50
+ updateParentBlockOnHmrReload ( parentInstance , instance , newInstance )
51
+ }
52
+
53
+ /**
54
+ * dev only
55
+ * update parentInstance.block to ensure that the correct parent and
56
+ * anchor are found during parentInstance HMR rerender/reload, as
57
+ * `normalizeBlock` relies on the current instance.block
58
+ */
59
+ function updateParentBlockOnHmrReload (
60
+ parentInstance : VaporComponentInstance | null ,
61
+ instance : VaporComponentInstance ,
62
+ newInstance : VaporComponentInstance ,
63
+ ) : void {
52
64
if ( parentInstance ) {
53
65
if ( parentInstance . block === instance ) {
54
66
parentInstance . block = newInstance
0 commit comments