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

Function patch

packages/runtime-core/src/renderer.ts:379–496  ·  view source on GitHub ↗
(
    n1,
    n2,
    container,
    anchor = null,
    parentComponent = null,
    parentSuspense = null,
    namespace = undefined,
    slotScopeIds = null,
    optimized = __DEV__ && isHmrUpdating ? false : !!n2.dynamicChildren,
  )

Source from the content-addressed store, hash-verified

377 // Note: functions inside this closure should use `const xxx = () => {}`
378 // style in order to prevent being inlined by minifiers.
379 const patch: PatchFn = (
380 n1,
381 n2,
382 container,
383 anchor = null,
384 parentComponent = null,
385 parentSuspense = null,
386 namespace = undefined,
387 slotScopeIds = null,
388 optimized = __DEV__ && isHmrUpdating ? false : !!n2.dynamicChildren,
389 ) => {
390 if (n1 === n2) {
391 return
392 }
393
394 // patching & not same type, unmount old tree
395 if (n1 && !isSameVNodeType(n1, n2)) {
396 anchor = getNextHostNode(n1)
397 unmount(n1, parentComponent, parentSuspense, true)
398 n1 = null
399 }
400
401 if (n2.patchFlag === PatchFlags.BAIL) {
402 optimized = false
403 n2.dynamicChildren = null
404 }
405
406 const { type, ref, shapeFlag } = n2
407 switch (type) {
408 case Text:
409 processText(n1, n2, container, anchor)
410 break
411 case Comment:
412 processCommentNode(n1, n2, container, anchor)
413 break
414 case Static:
415 if (n1 == null) {
416 mountStaticNode(n2, container, anchor, namespace)
417 } else if (__DEV__) {
418 patchStaticNode(n1, n2, container, namespace)
419 }
420 break
421 case Fragment:
422 processFragment(
423 n1,
424 n2,
425 container,
426 anchor,
427 parentComponent,
428 parentSuspense,
429 namespace,
430 slotScopeIds,
431 optimized,
432 )
433 break
434 default:
435 if (shapeFlag & ShapeFlags.ELEMENT) {
436 processElement(

Callers 13

mountChildrenFunction · 0.85
patchBlockChildrenFunction · 0.85
componentUpdateFnFunction · 0.85
patchUnkeyedChildrenFunction · 0.85
patchKeyedChildrenFunction · 0.85
renderFunction · 0.85
hydrateFunction · 0.85
hydrateChildrenFunction · 0.85
handleMismatchFunction · 0.85
setupFunction · 0.85
mountSuspenseFunction · 0.85
patchSuspenseFunction · 0.85

Calls 12

isSameVNodeTypeFunction · 0.90
warnFunction · 0.90
setRefFunction · 0.90
getNextHostNodeFunction · 0.85
processTextFunction · 0.85
processCommentNodeFunction · 0.85
mountStaticNodeFunction · 0.85
patchStaticNodeFunction · 0.85
processFragmentFunction · 0.85
processElementFunction · 0.85
processComponentFunction · 0.85
unmountFunction · 0.70

Tested by

no test coverage detected