Skip to content

Commit

Permalink
refactor: remove unncessary condition
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 authored and kiku-jw committed Jun 18, 2019
1 parent 4f3398e commit e17ab77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/vdom/helpers/resolve-async-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export function resolveAsyncComponent (
if (!isDef(factory.owners)) {
const owners = factory.owners = [owner]
let sync = true
if (owner) owner.$on('hook:destroyed', () => remove(owners, owner))

;(owner: any).$on('hook:destroyed', () => remove(owners, owner))

const forceRender = (renderCompleted: boolean) => {
for (let i = 0, l = owners.length; i < l; i++) {
Expand Down
6 changes: 6 additions & 0 deletions test/unit/modules/vdom/create-component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ describe('create-component', () => {
props: ['msg']
})
}
setCurrentRenderingInstance(vm)
const vnode = createComponent(async, data, vm, vm)
setCurrentRenderingInstance(null)
expect(vnode.asyncFactory).toBe(async)
expect(vnode.asyncFactory.owners.length).toEqual(0)
expect(vnode.tag).toMatch(/vue-component-[0-9]+-child/)
Expand Down Expand Up @@ -121,11 +123,15 @@ describe('create-component', () => {
}, 0)
}
function go () {
setCurrentRenderingInstance(vm)
vnode = createComponent(async, data, vm, vm)
setCurrentRenderingInstance(null)
expect(vnode.isComment).toBe(true) // not to be loaded yet.
}
function failed () {
setCurrentRenderingInstance(vm)
vnode = createComponent(async, data, vm, vm)
setCurrentRenderingInstance(null)
expect(vnode.isComment).toBe(true) // failed, still a comment node
expect(`Failed to resolve async component: ${async}\nReason: ${reason}`).toHaveBeenWarned()
done()
Expand Down

0 comments on commit e17ab77

Please sign in to comment.