vue3-core/packages/runtime-vapor/src/hmr.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
944 B
TypeScript
Raw Normal View History

2024-12-08 17:20:34 +08:00
import {
currentInstance,
2024-12-08 17:20:34 +08:00
popWarningContext,
pushWarningContext,
simpleSetCurrentInstance,
2024-12-08 17:20:34 +08:00
} from '@vue/runtime-core'
import { normalizeBlock } from './block'
import { type VaporComponentInstance, devRender } from './component'
import { insert, remove } from './dom/node'
export function hmrRerender(instance: VaporComponentInstance): void {
const normalized = normalizeBlock(instance.block)
const parent = normalized[0].parentNode!
const anchor = normalized[normalized.length - 1].nextSibling
remove(instance.block, parent)
const prev = currentInstance
simpleSetCurrentInstance(instance)
2024-12-08 17:20:34 +08:00
pushWarningContext(instance)
devRender(instance)
popWarningContext()
simpleSetCurrentInstance(prev, instance)
2024-12-08 17:20:34 +08:00
insert(instance.block, parent, anchor)
}
2024-12-08 21:22:51 +08:00
export function hmrReload(instance: VaporComponentInstance): void {
// in parent block, find the corresponding block of this instance
// create new instance, replace
}