import { ComponentInternalInstance , ssrContextKey } from 'vue' ; import { createBuffer , PushFn , SSRBufferItem , SSRContext } from '../render' ; export function ssrRenderTeleport ( parentPush , contentRenderFn , target , disabled , parentComponent ) { parentPush ( '<!--teleport start-->' ) ; let teleportContent ; if ( disabled ) { contentRenderFn ( parentPush ) ; teleportContent = `<!---->` ; } else { const { getBuffer , push } = createBuffer ( ) ; contentRenderFn ( push ) ; push ( `<!---->` ) ; teleportContent = getBuffer ( ) ; } const context = parentComponent . appContext . provides [ ssrContextKey as any ] as SSRContext ; const teleportBuffers = context . __teleportBuffers || ( context . __teleportBuffers = { } ) ; if ( teleportBuffers [ target ] ) { teleportBuffers [ target ] . push ( teleportContent ) ; } else { teleportBuffers [ target ] = [ teleportContent ] ; } parentPush ( '<!--teleport end-->' ) ; }