Skip to content

Commit 5fb1d0a

Browse files
committed
chore: tweaks
1 parent a99b1ef commit 5fb1d0a

File tree

1 file changed

+16
-4
lines changed
  • packages/runtime-vapor/src

1 file changed

+16
-4
lines changed

packages/runtime-vapor/src/hmr.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import {
1313
unmountComponent,
1414
} from './component'
1515
import { isArray } from '@vue/shared'
16+
1617
export function hmrRerender(instance: VaporComponentInstance): void {
1718
const normalized = normalizeBlock(instance.block)
1819
const parent = normalized[0].parentNode!
1920
const anchor = normalized[normalized.length - 1].nextSibling
2021
remove(instance.block, parent)
21-
instance.scope!.cleanup()
22+
instance.scope.cleanup()
2223
const prev = setCurrentInstance(instance)
2324
pushWarningContext(instance)
2425
devRender(instance)
@@ -46,9 +47,20 @@ export function hmrReload(
4647
setCurrentInstance(...prev)
4748
mountComponent(newInstance, parent, anchor)
4849

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 {
5264
if (parentInstance) {
5365
if (parentInstance.block === instance) {
5466
parentInstance.block = newInstance

0 commit comments

Comments
 (0)