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

Function patchSuspense

packages/runtime-core/src/components/Suspense.ts:227–420  ·  packages/runtime-core/src/components/Suspense.ts::patchSuspense
(
  n1: VNode,
  n2: VNode,
  container: RendererElement,
  anchor: RendererNode | null,
  parentComponent: ComponentInternalInstance | null,
  namespace: ElementNamespace,
  slotScopeIds: string[] | null,
  optimized: boolean,
  { p: patch, um: unmount, o: { createElement } }: RendererInternals,
)

Source from the content-addressed store, hash-verified

225}
226
227function patchSuspense(
228 n1: VNode,
229 n2: VNode,
230 container: RendererElement,
231 anchor: RendererNode | null,
232 parentComponent: ComponentInternalInstance | null,
233 namespace: ElementNamespace,
234 slotScopeIds: string[] | null,
235 optimized: boolean,
236 { p: patch, um: unmount, o: { createElement } }: RendererInternals,
237) {
238 const suspense = (n2.suspense = n1.suspense)!
239 suspense.vnode = n2
240 n2.el = n1.el
241 const newBranch = n2.ssContent!
242 const newFallback = n2.ssFallback!
243
244 const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense
245 if (pendingBranch) {
246 suspense.pendingBranch = newBranch
247 if (isSameVNodeType(pendingBranch, newBranch)) {
248 class="cm">// same root type but content may have changed.
249 patch(
250 pendingBranch,
251 newBranch,
252 suspense.hiddenContainer,
253 null,
254 parentComponent,
255 suspense,
256 namespace,
257 slotScopeIds,
258 optimized,
259 )
260 if (suspense.deps <= 0) {
261 suspense.resolve()
262 } else if (isInFallback) {
263 class="cm">// It's possible that the app is in hydrating state when patching the
264 class="cm">// suspense instance. If someone updates the dependency during component
265 class="cm">// setup in children of suspense boundary, that would be problemtic
266 class="cm">// because we aren't actually showing a fallback content when
267 class="cm">// patchSuspense is called. In such case, patch of fallback content
268 class="cm">// should be no op
269 if (!isHydrating) {
270 patch(
271 activeBranch,
272 newFallback,
273 container,
274 anchor,
275 parentComponent,
276 null, class="cm">// fallback tree will not have suspense context
277 namespace,
278 slotScopeIds,
279 optimized,
280 )
281 setActiveBranch(suspense, newFallback)
282 }
283 }
284 } else {

Callers 1

processFunction · 0.85

Calls 8

isSameVNodeTypeFunction · 0.90
patchFunction · 0.85
setActiveBranchFunction · 0.85
createElementFunction · 0.85
fallbackMethod · 0.80
unmountFunction · 0.70
triggerEventFunction · 0.70
resolveMethod · 0.65

Tested by

no test coverage detected