Skip to content

Commit 932ddd0

Browse files
authored
fix(runtime-core): handle non-isomorphic block element update (#15002)
fix #6385
1 parent 31d0f23 commit 932ddd0

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎packages/runtime-core/__tests__/rendererOptimizedMode.spec.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,29 @@ describe('renderer: optimized mode', () => {
825825
expect(inner(root)).toBe('<div><div><span>loading</span></div></div>')
826826
})
827827

828+
// #6385
829+
test('should fully diff props when falling back from a non-isomorphic block', () => {
830+
render(h('div', { id: 'placeholder' }), root)
831+
832+
render(
833+
(openBlock(),
834+
createElementBlock(
835+
'div',
836+
{ class: 'resolved' },
837+
[
838+
createTextVNode('hello '),
839+
createElementVNode('button', null, '0', PatchFlags.TEXT),
840+
],
841+
PatchFlags.CLASS,
842+
)),
843+
root,
844+
)
845+
846+
expect(inner(root)).toBe(
847+
'<div class="resolved">hello <button>0</button></div>',
848+
)
849+
})
850+
828851
// #3828
829852
test('patch Suspense in optimized mode w/ nested dynamic nodes', async () => {
830853
const show = ref(false)

‎packages/runtime-core/src/renderer.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,15 @@ function baseCreateRenderer(
855855
}
856856
parentComponent && toggleRecurse(parentComponent, true)
857857

858-
if (__DEV__ && isHmrUpdating) {
858+
if (
859859
// 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+
) {
860867
patchFlag = 0
861868
optimized = false
862869
dynamicChildren = null

0 commit comments

Comments
 (0)