8000 fix(Teleport): hydrate disabled Teleport with undefined target by linzhe141 · Pull Request #11235 · vuejs/core · GitHub
[go: up one dir, main page]

Skip to content

fix(Teleport): hydrate disabled Teleport with undefined target #11235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
chore: update
  • Loading branch information
linzhe141 committed Aug 10, 2024
commit b15cbac7889385eb7947659fd42ac77d3cc3ca41
44 changes: 24 additions & 20 deletions packages/runtime-core/src/components/Teleport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,25 @@ function hydrateTeleport(
optimized: boolean,
) => Node | null,
): Node | null {
function hydrateDisabledTeleport(
node: Node,
vnode: VNode,
targetStart: Node | null,
targetAnchor: Node | null,
) {
vnode.anchor = hydrateChildren(
nextSibling(node),
vnode,
parentNode(node)!,
parentComponent,
parentSuspense,
slotScopeIds,
optimized,
)
vnode.targetStart = targetStart
vnode.targetAnchor = targetAnchor
}

const target = (vnode.target = resolveTarget<Element>(
vnode.props,
querySelector,
Expand All @@ -372,17 +391,12 @@ function hydrateTeleport(
(target as TeleportTargetElement)._lpa || target.firstChild
if (vnode.shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
if (isTeleportDisabled(vnode.props)) {
vnode.anchor = hydrateChildren(
nextSibling(node),
hydrateDisabledTeleport(
node,
vnode,
parentNode(node)!,
parentComponent,
parentSuspense,
slotScopeIds,
optimized,
targetNode,
targetNode && nextSibling(targetNode),
)
vnode.targetStart = targetNode
vnode.targetAnchor = targetNode && nextSibling(targetNode)
} else {
vnode.anchor = nextSibling(node)

Expand Down Expand Up @@ -426,17 +440,7 @@ function hydrateTeleport(
updateCssVars(vnode)
} else if (isTeleportDisabled(vnode.props)) {
if (vnode.shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
vnode.anchor = hydrateChildren(
nextSibling(node),
vnode,
parentNode(node)!,
parentComponent,
parentSuspense,
slotScopeIds,
optimized,
)
vnode.targetStart = node
vnode.targetAnchor = nextSibling(node)
hydrateDisabledTeleport(node, vnode, node, nextSibling(node))
}
}
return vnode.anchor && nextSibling(vnode.anchor as Node)
Expand Down
0