Skip to content

Commit 5260830

Browse files
contribumac2
contribu
and
mac2
authoredApr 16, 2021
fix(core): fix sameVnode for async component (#11107)
Co-authored-by: mac2 <mac2@example.com>
1 parent e4dea59 commit 5260830

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
 

‎src/core/vdom/patch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ const hooks = ['create', 'activate', 'update', 'remove', 'destroy']
3434

3535
function sameVnode (a, b) {
3636
return (
37-
a.key === b.key && (
37+
a.key === b.key &&
38+
a.asyncFactory === b.asyncFactory && (
3839
(
3940
a.tag === b.tag &&
4041
a.isComment === b.isComment &&
4142
isDef(a.data) === isDef(b.data) &&
4243
sameInputType(a, b)
4344
) || (
4445
isTrue(a.isAsyncPlaceholder) &&
45-
a.asyncFactory === b.asyncFactory &&
4646
isUndef(b.asyncFactory.error)
4747
)
4848
)

‎test/unit/modules/vdom/patch/edge-cases.spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Vue from 'vue'
2+
import { SSR_ATTR } from 'shared/constants'
23

34
describe('vdom patch: edge cases', () => {
45
// exposed by #3406
@@ -432,4 +433,22 @@ describe('vdom patch: edge cases', () => {
432433
expect(vm.$el.textContent).not.toMatch('Infinity')
433434
}).then(done)
434435
})
436+
437+
it('should not throw when hydrated pending async component is patched by v-if="false"', done => {
438+
const PendingAsyncComponent = () => new Promise(() => {})
439+
const ssrAsyncComponent = document.createElement('div')
440+
ssrAsyncComponent.setAttribute(SSR_ATTR, 'true')
441+
const vm = new Vue({
442+
data: {
443+
visible: true
444+
},
445+
components: {
446+
PendingAsyncComponent
447+
},
448+
template: '<pending-async-component v-if="visible"></pending-async-component>'
449+
}).$mount(ssrAsyncComponent)
450+
451+
vm.visible = false
452+
vm.$nextTick(done)
453+
})
435454
})

0 commit comments

Comments
 (0)
Please sign in to comment.