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

View File

@ -85,7 +85,7 @@ export const VaporTeleportImpl = {
}, },
} }
class TeleportFragment extends VaporFragment { export class TeleportFragment extends VaporFragment {
anchor: Node anchor: Node
private targetStart?: 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 * dev only
* during root component HMR reload, since the old component will be unmounted * during root component HMR reload, since the old component will be unmounted