Skip to content

Commit d13774b

Browse files
committed
perf: skip patch on same vnode
1 parent dd1439e commit d13774b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

packages/runtime-core/src/renderer.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,10 @@ function baseCreateRenderer(
470470
slotScopeIds = null,
471471
optimized = __DEV__ && isHmrUpdating ? false : !!n2.dynamicChildren
472472
) => {
473+
if (n1 === n2) {
474+
return
475+
}
476+
473477
// patching & not same type, unmount old tree
474478
if (n1 && !isSameVNodeType(n1, n2)) {
475479
anchor = getNextHostNode(n1)
@@ -1152,8 +1156,12 @@ function baseCreateRenderer(
11521156
const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''))!
11531157

11541158
let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2
1155-
if (dynamicChildren) {
1156-
optimized = true
1159+
1160+
if (__DEV__ && isHmrUpdating) {
1161+
// HMR updated, force full diff
1162+
patchFlag = 0
1163+
optimized = false
1164+
dynamicChildren = null
11571165
}
11581166

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

1166-
if (__DEV__ && isHmrUpdating) {
1167-
// HMR updated, force full diff
1168-
patchFlag = 0
1169-
optimized = false
1170-
dynamicChildren = null
1171-
}
1172-
11731174
if (n1 == null) {
11741175
hostInsert(fragmentStartAnchor, container, anchor)
11751176
hostInsert(fragmentEndAnchor, container, anchor)

0 commit comments

Comments
 (0)