Skip to content

Commit

Permalink
refactor: remove unncessary condition
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 28, 2019
1 parent ed34113 commit 03c13de
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))

This comment has been minimized.

Copy link
@derz

derz Mar 5, 2019

Hi @yyx990803
Removing the condition breaks if a functional component contains a (globally registered via Vue.component) async component (not sure where that should be fixed or if it is already wrong design-wise, but it worked prior to 2.6.8). Should I open a new Issue?

This comment has been minimized.

Copy link
@posva

posva Mar 5, 2019

Member

yes, you should open a new issue with a repro, thank you 🙂


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 03c13de

Please sign in to comment.