1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| export function patch( n1: VNode | null, n2: VNode, container: RendererElement, anchor: RendererNode | null, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, isSVG: boolean, slotScopeIds: string[] | null, optimized: boolean ) { if (n1 && isSameVNodeType(n1, n2)) { patchElement( n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized ); } else { if (n1) { unmount(n1, parentComponent, parentSuspense, true); } mountElement( n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized ); } }
function patchElement( n1: VNode, n2: VNode, container: RendererElement, anchor: RendererNode | null, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, isSVG: boolean, slotScopeIds: string[] | null, optimized: boolean ) { const el = (n2.el = n1.el!);
const oldPatchFlag = n1.patchFlag; const newPatchFlag = n2.patchFlag;
if (newPatchFlag > 0) { if (newPatchFlag & PatchFlags.FULL_PROPS) { patchProps( el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG ); } else { if (newPatchFlag & PatchFlags.CLASS) { if (oldProps.class !== newProps.class) { hostPatchProp(el, "class", null, newProps.class, isSVG); } } if (newPatchFlag & PatchFlags.STYLE) { hostPatchProp(el, "style", oldProps.style, newProps.style, isSVG); } } }
patchChildren( n1, n2, el, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized ); }
|