Skip to content

Commit

Permalink
perf: skip patch on same vnode
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 21, 2021
1 parent dd1439e commit d13774b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ function baseCreateRenderer(
slotScopeIds = null,
optimized = __DEV__ && isHmrUpdating ? false : !!n2.dynamicChildren
) => {
if (n1 === n2) {
return
}

// patching & not same type, unmount old tree
if (n1 && !isSameVNodeType(n1, n2)) {
anchor = getNextHostNode(n1)
Expand Down Expand Up @@ -1152,8 +1156,12 @@ function baseCreateRenderer(
const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''))!

let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2
if (dynamicChildren) {
optimized = true

if (__DEV__ && isHmrUpdating) {
// HMR updated, force full diff
patchFlag = 0
optimized = false
dynamicChildren = null
}

// check if this is a slot fragment with :slotted scope ids
Expand All @@ -1163,13 +1171,6 @@ function baseCreateRenderer(
: fragmentSlotScopeIds
}

if (__DEV__ && isHmrUpdating) {
// HMR updated, force full diff
patchFlag = 0
optimized = false
dynamicChildren = null
}

if (n1 == null) {
hostInsert(fragmentStartAnchor, container, anchor)
hostInsert(fragmentEndAnchor, container, anchor)
Expand Down

0 comments on commit d13774b

Please sign in to comment.