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

Function resolve

packages/runtime-core/src/components/Suspense.ts:523–648  ·  view source on GitHub ↗
(resume = false, sync = false)

Source from the content-addressed store, hash-verified

521 effects: [],
522
523 resolve(resume = false, sync = false) {
524 if (__DEV__) {
525 if (!resume && !suspense.pendingBranch) {
526 throw new Error(
527 `suspense.resolve() is called without a pending branch.`,
528 )
529 }
530 if (suspense.isUnmounted) {
531 throw new Error(
532 `suspense.resolve() is called on an already unmounted suspense boundary.`,
533 )
534 }
535 }
536 const {
537 vnode,
538 activeBranch,
539 pendingBranch,
540 pendingId,
541 effects,
542 parentComponent,
543 container,
544 isInFallback,
545 } = suspense
546
547 // if there's a transition happening we need to wait it to finish.
548 let delayEnter: boolean | null = false
549 if (suspense.isHydrating) {
550 suspense.isHydrating = false
551 } else if (!resume) {
552 delayEnter =
553 activeBranch &&
554 pendingBranch!.transition &&
555 pendingBranch!.transition.mode === 'out-in'
556 let hasUpdatedAnchor = false
557 if (delayEnter) {
558 activeBranch!.transition!.afterLeave = () => {
559 if (pendingId === suspense.pendingId) {
560 move(
561 pendingBranch!,
562 container,
563 anchor === initialAnchor && !hasUpdatedAnchor
564 ? next(activeBranch!)
565 : anchor,
566 MoveType.ENTER,
567 )
568 queuePostFlushCb(effects)
569 // clear el reference from fallback vnode to allow GC after transition
570 if (isInFallback && vnode.ssFallback) {
571 vnode.ssFallback.el = null
572 }
573 }
574 }
575 }
576 // unmount current active tree
577 // #7966 when Suspense is wrapped in Transition, fallback may wait for
578 // afterLeave before mounting. In that window, activeBranch is still the
579 // leaving content, so avoid unmounting it again during resolve.
580 if (activeBranch && !suspense.isFallbackMountPending) {

Callers 15

gcFunction · 0.50
promisifyStreamFunction · 0.50
pushFunction · 0.50
gcFunction · 0.50
userRetryFunction · 0.50
hydration.spec.tsFile · 0.50
setupFunction · 0.50
setupFunction · 0.50
Suspense.spec.tsFile · 0.50

Calls 9

queuePostFlushCbFunction · 0.90
parentNodeFunction · 0.85
setActiveBranchFunction · 0.85
moveFunction · 0.70
nextFunction · 0.70
unmountFunction · 0.70
triggerEventFunction · 0.70
pushMethod · 0.65
resolveMethod · 0.65

Tested by 9

gcFunction · 0.40
promisifyStreamFunction · 0.40
pushFunction · 0.40
gcFunction · 0.40
setupFunction · 0.40
setupFunction · 0.40
installVueGlobalBuildFunction · 0.40
waitForSelectorFunction · 0.40
nextFrameFunction · 0.40