(
n1: VNode,
n2: VNode,
parentComponent: ComponentInternalInstance | null,
parentSuspense: SuspenseBoundary | null,
namespace: ElementNamespace,
slotScopeIds: string[] | null,
optimized: boolean,
)
| 825 | } |
| 826 | |
| 827 | const patchElement = ( |
| 828 | n1: VNode, |
| 829 | n2: VNode, |
| 830 | parentComponent: ComponentInternalInstance | null, |
| 831 | parentSuspense: SuspenseBoundary | null, |
| 832 | namespace: ElementNamespace, |
| 833 | slotScopeIds: string[] | null, |
| 834 | optimized: boolean, |
| 835 | ) => { |
| 836 | const el = (n2.el = n1.el!) |
| 837 | if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { |
| 838 | el.__vnode = n2 |
| 839 | } |
| 840 | let { patchFlag, dynamicChildren, dirs } = n2 |
| 841 | // #1426 take the old vnode's patch flag into account since user may clone a |
| 842 | // compiler-generated vnode, which de-opts to FULL_PROPS |
| 843 | patchFlag |= n1.patchFlag & PatchFlags.FULL_PROPS |
| 844 | const oldProps = n1.props || EMPTY_OBJ |
| 845 | const newProps = n2.props || EMPTY_OBJ |
| 846 | let vnodeHook: VNodeHook | undefined | null |
| 847 | |
| 848 | // disable recurse in beforeUpdate hooks |
| 849 | parentComponent && toggleRecurse(parentComponent, false) |
| 850 | if ((vnodeHook = newProps.onVnodeBeforeUpdate)) { |
| 851 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1) |
| 852 | } |
| 853 | if (dirs) { |
| 854 | invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate') |
| 855 | } |
| 856 | parentComponent && toggleRecurse(parentComponent, true) |
| 857 | |
| 858 | if ( |
| 859 | // HMR updated, force full diff |
| 860 | (__DEV__ && isHmrUpdating) || |
| 861 | // #6385 the old vnode may be a user-wrapped non-isomorphic block |
| 862 | // Force full diff when block metadata is unstable. |
| 863 | (dynamicChildren && |
| 864 | (!n1.dynamicChildren || |
| 865 | n1.dynamicChildren.length !== dynamicChildren.length)) |
| 866 | ) { |
| 867 | patchFlag = 0 |
| 868 | optimized = false |
| 869 | dynamicChildren = null |
| 870 | } |
| 871 | |
| 872 | // #9135 innerHTML / textContent unset needs to happen before possible |
| 873 | // new children mount |
| 874 | if ( |
| 875 | (oldProps.innerHTML && newProps.innerHTML == null) || |
| 876 | (oldProps.textContent && newProps.textContent == null) |
| 877 | ) { |
| 878 | hostSetElementText(el, '') |
| 879 | } |
| 880 | |
| 881 | if (dynamicChildren) { |
| 882 | patchBlockChildren( |
| 883 | n1.dynamicChildren!, |
| 884 | dynamicChildren, |
no test coverage detected