wip: refactor

This commit is contained in:
daiwei 2025-03-27 14:36:02 +08:00
parent fd6f163246
commit 4de819c267
2 changed files with 10 additions and 9 deletions

View File

@ -60,7 +60,7 @@ import {
import { hmrReload, hmrRerender } from './hmr'
import { isHydrating, locateHydrationNode } from './dom/hydration'
import { insertionAnchor, insertionParent } from './insertionState'
import type { VaporTeleportImpl } from './components/Teleport'
import { isVaporTeleport } from './components/Teleport'
export { currentInstance } from '@vue/runtime-dom'
@ -93,8 +93,6 @@ export interface ObjectVaporComponent
name?: string
vapor?: boolean
__isTeleport?: boolean
}
interface SharedInternalOptions {
@ -161,11 +159,8 @@ export function createComponent(
}
// teleport
if (component.__isTeleport) {
const frag = (component as typeof VaporTeleportImpl).process(
rawProps!,
rawSlots!,
)
if (isVaporTeleport(component)) {
const frag = component.process(rawProps!, rawSlots!)
if (!isHydrating && _insertionParent) {
insert(frag, _insertionParent, _insertionAnchor)
} else {

View File

@ -85,7 +85,7 @@ export const VaporTeleportImpl = {
},
}
class TeleportFragment extends VaporFragment {
export class TeleportFragment extends VaporFragment {
anchor: Node
private targetStart?: Node
@ -242,6 +242,12 @@ export const VaporTeleport = VaporTeleportImpl as unknown as {
}
}
export function isVaporTeleport(
value: unknown,
): value is typeof VaporTeleportImpl {
return value === VaporTeleportImpl
}
/**
* dev only
* during root component HMR reload, since the old component will be unmounted