MCPcopy
hub / github.com/vuejs/core / fallback

Function fallback

packages/runtime-core/src/components/Suspense.ts:650–701  ·  view source on GitHub ↗
(fallbackVNode)

Source from the content-addressed store, hash-verified

648 },
649
650 fallback(fallbackVNode) {
651 if (!suspense.pendingBranch) {
652 return
653 }
654
655 const { vnode, activeBranch, parentComponent, container, namespace } =
656 suspense
657
658 // invoke @fallback event
659 triggerEvent(vnode, 'onFallback')
660
661 const anchor = next(activeBranch!)
662 const mountFallback = () => {
663 suspense.isFallbackMountPending = false
664 if (!suspense.isInFallback) {
665 return
666 }
667 // mount the fallback tree
668 patch(
669 null,
670 fallbackVNode,
671 container,
672 anchor,
673 parentComponent,
674 null, // fallback tree will not have suspense context
675 namespace,
676 slotScopeIds,
677 optimized,
678 )
679 setActiveBranch(suspense, fallbackVNode)
680 }
681
682 const delayEnter =
683 fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in'
684 if (delayEnter) {
685 suspense.isFallbackMountPending = true
686 activeBranch!.transition!.afterLeave = mountFallback
687 }
688 suspense.isInFallback = true
689
690 // unmount current active branch
691 unmount(
692 activeBranch!,
693 parentComponent,
694 null, // no suspense so unmount hooks fire now
695 true, // shouldRemove
696 )
697
698 if (!delayEnter) {
699 mountFallback()
700 }
701 },
702
703 move(container, anchor, type) {
704 suspense.activeBranch &&

Callers 1

renderSlotFunction · 0.85

Calls 4

mountFallbackFunction · 0.85
triggerEventFunction · 0.70
nextFunction · 0.70
unmountFunction · 0.70

Tested by

no test coverage detected