(
n1,
n2,
container,
anchor = null,
parentComponent = null,
parentSuspense = null,
namespace = undefined,
slotScopeIds = null,
optimized = __DEV__ && isHmrUpdating ? false : !!n2.dynamicChildren,
)
| 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( |
no test coverage detected