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

Function mountSuspense

packages/runtime-core/src/components/Suspense.ts:162–225  ·  view source on GitHub ↗
(
  vnode: VNode,
  container: RendererElement,
  anchor: RendererNode | null,
  parentComponent: ComponentInternalInstance | null,
  parentSuspense: SuspenseBoundary | null,
  namespace: ElementNamespace,
  slotScopeIds: string[] | null,
  optimized: boolean,
  rendererInternals: RendererInternals,
)

Source from the content-addressed store, hash-verified

160}
161
162function mountSuspense(
163 vnode: VNode,
164 container: RendererElement,
165 anchor: RendererNode | null,
166 parentComponent: ComponentInternalInstance | null,
167 parentSuspense: SuspenseBoundary | null,
168 namespace: ElementNamespace,
169 slotScopeIds: string[] | null,
170 optimized: boolean,
171 rendererInternals: RendererInternals,
172) {
173 const {
174 p: patch,
175 o: { createElement },
176 } = rendererInternals
177 const hiddenContainer = createElement('div')
178 const suspense = (vnode.suspense = createSuspenseBoundary(
179 vnode,
180 parentSuspense,
181 parentComponent,
182 container,
183 hiddenContainer,
184 anchor,
185 namespace,
186 slotScopeIds,
187 optimized,
188 rendererInternals,
189 ))
190
191 // start mounting the content subtree in an off-dom container
192 patch(
193 null,
194 (suspense.pendingBranch = vnode.ssContent!),
195 hiddenContainer,
196 null,
197 parentComponent,
198 suspense,
199 namespace,
200 slotScopeIds,
201 )
202 // now check if we have encountered any async deps
203 if (suspense.deps > 0) {
204 // has async
205 // invoke @fallback event
206 triggerEvent(vnode, 'onPending')
207 triggerEvent(vnode, 'onFallback')
208
209 // mount the fallback tree
210 patch(
211 null,
212 vnode.ssFallback!,
213 container,
214 anchor,
215 parentComponent,
216 null, // fallback tree will not have suspense context
217 namespace,
218 slotScopeIds,
219 )

Callers 1

processFunction · 0.85

Calls 6

createElementFunction · 0.85
createSuspenseBoundaryFunction · 0.85
patchFunction · 0.85
setActiveBranchFunction · 0.85
triggerEventFunction · 0.70
resolveMethod · 0.65

Tested by

no test coverage detected