Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: handle non-isomorphic block element update
  • Loading branch information
KazariEX committed Jun 24, 2026
commit 303de0e6504d2737841cdca7cb838b952f74ddd0
18 changes: 18 additions & 0 deletions packages/runtime-core/__tests__/rendererOptimizedMode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,24 @@ describe('renderer: optimized mode', () => {
expect(inner(root)).toBe('<div><div><span>loading</span></div></div>')
})

// #6385
test('should fall back to full diff when the user patches a compiled slot', () => {
render(h('div', { id: 'placeholder' }), root)

render(
(openBlock(),
createElementBlock('div', { id: 'resolved' }, [
createTextVNode('hello '),
createElementVNode('button', null, '0', PatchFlags.TEXT),
])),
root,
)

expect(inner(root)).toBe(
'<div id="resolved">hello <button>0</button></div>',
)
})

// #3828
test('patch Suspense in optimized mode w/ nested dynamic nodes', async () => {
const show = ref(false)
Expand Down
40 changes: 23 additions & 17 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,15 @@ function baseCreateRenderer(
}
parentComponent && toggleRecurse(parentComponent, true)

if (__DEV__ && isHmrUpdating) {
// HMR updated, force full diff
// #6385 the old vnode may be a user-wrapped non-isomorphic block
const isFullDiffRequired = !(
dynamicChildren &&
n1.dynamicChildren &&
n1.dynamicChildren.length === dynamicChildren.length
)

// HMR updated, force full diff
if (isFullDiffRequired || (__DEV__ && isHmrUpdating)) {
patchFlag = 0
optimized = false
dynamicChildren = null
Expand All @@ -871,33 +878,32 @@ function baseCreateRenderer(
hostSetElementText(el, '')
}

if (dynamicChildren) {
patchBlockChildren(
n1.dynamicChildren!,
dynamicChildren,
if (isFullDiffRequired) {
patchChildren(
n1,
n2,
el,
null,
parentComponent,
parentSuspense,
resolveChildrenNamespace(n2, namespace),
slotScopeIds,
false,
)
if (__DEV__) {
// necessary for HMR
traverseStaticChildren(n1, n2)
}
} else if (!optimized) {
// full diff
patchChildren(
n1,
n2,
} else {
patchBlockChildren(
n1.dynamicChildren!,
dynamicChildren!,
el,
null,
parentComponent,
parentSuspense,
resolveChildrenNamespace(n2, namespace),
slotScopeIds,
false,
)
if (__DEV__) {
// necessary for HMR
traverseStaticChildren(n1, n2)
}
}

if (patchFlag > 0) {
Expand Down
Loading