|
|
@@ -11,6 +11,8 @@ import { VNode, VNodeArrayChildren, VNodeProps } from '../vnode'
|
|
|
import { isString, ShapeFlags } from '@vue/shared'
|
|
|
import { warn } from '../warning'
|
|
|
|
|
|
+export type TeleportVNode = VNode<RendererNode, RendererElement, TeleportProps>
|
|
|
+
|
|
|
export interface TeleportProps {
|
|
|
to: string | RendererElement
|
|
|
disabled?: boolean
|
|
|
@@ -55,8 +57,8 @@ const resolveTarget = <T = RendererElement>(
|
|
|
export const TeleportImpl = {
|
|
|
__isTeleport: true,
|
|
|
process(
|
|
|
- n1: VNode | null,
|
|
|
- n2: VNode,
|
|
|
+ n1: TeleportVNode | null,
|
|
|
+ n2: TeleportVNode,
|
|
|
container: RendererElement,
|
|
|
anchor: RendererNode | null,
|
|
|
parentComponent: ComponentInternalInstance | null,
|
|
|
@@ -85,10 +87,7 @@ export const TeleportImpl = {
|
|
|
insert(placeholder, container, anchor)
|
|
|
insert(mainAnchor, container, anchor)
|
|
|
|
|
|
- const target = (n2.target = resolveTarget(
|
|
|
- n2.props as TeleportProps,
|
|
|
- querySelector
|
|
|
- ))
|
|
|
+ const target = (n2.target = resolveTarget(n2.props, querySelector))
|
|
|
const targetAnchor = (n2.targetAnchor = createText(''))
|
|
|
if (target) {
|
|
|
insert(targetAnchor, target)
|
|
|
@@ -165,7 +164,7 @@ export const TeleportImpl = {
|
|
|
// target changed
|
|
|
if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
|
|
const nextTarget = (n2.target = resolveTarget(
|
|
|
- n2.props as TeleportProps,
|
|
|
+ n2.props,
|
|
|
querySelector
|
|
|
))
|
|
|
if (nextTarget) {
|
|
|
@@ -267,7 +266,7 @@ interface TeleportTargetElement extends Element {
|
|
|
|
|
|
function hydrateTeleport(
|
|
|
node: Node,
|
|
|
- vnode: VNode,
|
|
|
+ vnode: TeleportVNode,
|
|
|
parentComponent: ComponentInternalInstance | null,
|
|
|
parentSuspense: SuspenseBoundary | null,
|
|
|
optimized: boolean,
|
|
|
@@ -284,7 +283,7 @@ function hydrateTeleport(
|
|
|
) => Node | null
|
|
|
): Node | null {
|
|
|
const target = (vnode.target = resolveTarget<Element>(
|
|
|
- vnode.props as TeleportProps,
|
|
|
+ vnode.props,
|
|
|
querySelector
|
|
|
))
|
|
|
if (target) {
|