Skip to content

Commit

Permalink
fix(core): fix sameVnode for async component (#11107)
Browse files Browse the repository at this point in the history
Co-authored-by: mac2 <mac2@example.com>
  • Loading branch information
contribu and mac2 committed Apr 16, 2021
1 parent e4dea59 commit 5260830
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/vdom/patch.js
Expand Up @@ -34,15 +34,15 @@ const hooks = ['create', 'activate', 'update', 'remove', 'destroy']

function sameVnode (a, b) {
return (
a.key === b.key && (
a.key === b.key &&
a.asyncFactory === b.asyncFactory && (
(
a.tag === b.tag &&
a.isComment === b.isComment &&
isDef(a.data) === isDef(b.data) &&
sameInputType(a, b)
) || (
isTrue(a.isAsyncPlaceholder) &&
a.asyncFactory === b.asyncFactory &&
isUndef(b.asyncFactory.error)
)
)
Expand Down
19 changes: 19 additions & 0 deletions test/unit/modules/vdom/patch/edge-cases.spec.js
@@ -1,4 +1,5 @@
import Vue from 'vue'
import { SSR_ATTR } from 'shared/constants'

describe('vdom patch: edge cases', () => {
// exposed by #3406
Expand Down Expand Up @@ -432,4 +433,22 @@ describe('vdom patch: edge cases', () => {
expect(vm.$el.textContent).not.toMatch('Infinity')
}).then(done)
})

it('should not throw when hydrated pending async component is patched by v-if="false"', done => {
const PendingAsyncComponent = () => new Promise(() => {})
const ssrAsyncComponent = document.createElement('div')
ssrAsyncComponent.setAttribute(SSR_ATTR, 'true')
const vm = new Vue({
data: {
visible: true
},
components: {
PendingAsyncComponent
},
template: '<pending-async-component v-if="visible"></pending-async-component>'
}).$mount(ssrAsyncComponent)

vm.visible = false
vm.$nextTick(done)
})
})

0 comments on commit 5260830

Please sign in to comment.