@@ -94,7 +94,7 @@ export const TeleportImpl = {
9494 mc : mountChildren ,
9595 pc : patchChildren ,
9696 pbc : patchBlockChildren ,
97- o : { insert, querySelector, createText, createComment } ,
97+ o : { insert, querySelector, createText, createComment, parentNode } ,
9898 } = internals
9999
100100 const disabled = isTeleportDisabled ( n2 . props )
@@ -162,7 +162,11 @@ export const TeleportImpl = {
162162 if ( pendingMounts . get ( vnode ) !== mountJob ) return
163163 pendingMounts . delete ( vnode )
164164 if ( isTeleportDisabled ( vnode . props ) ) {
165- mount ( vnode , container , vnode . anchor ! )
165+ // Use the current parent of the placeholder instead of the
166+ // captured `container`, which may be stale if Suspense has moved
167+ // the branch to a different container during resolve.
168+ const mountContainer = parentNode ( vnode . el ! ) || container
169+ mount ( vnode , mountContainer , vnode . anchor ! )
166170 updateCssVars ( vnode , true )
167171 }
168172 mountToTarget ( vnode )
@@ -389,7 +393,8 @@ function moveTeleport(
389393 // if this is a re-order and teleport is enabled (content is in target)
390394 // do not move children. So the opposite is: only move children if this
391395 // is not a reorder, or the teleport is disabled
392- if ( ! isReorder || isTeleportDisabled ( props ) ) {
396+ // #14701 don't move children if in pending mount
397+ if ( ! pendingMounts . has ( vnode ) && ( ! isReorder || isTeleportDisabled ( props ) ) ) {
393398 // Teleport has either Array children or no children.
394399 if ( shapeFlag & ShapeFlags . ARRAY_CHILDREN ) {
395400 for ( let i = 0 ; i < ( children as VNode [ ] ) . length ; i ++ ) {
0 commit comments