Skip to content

Commit b663fc4

Browse files
committed
fix(validators): support components returning render function from setup
fix vuejs#1596
1 parent 69ea054 commit b663fc4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

packages/shared/validators.js

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export function isVueComponent(c: any): boolean {
4545
return true
4646
}
4747

48+
if (typeof c.setup === 'function' && !c.render) {
49+
return true
50+
}
51+
4852
return typeof c.render === 'function'
4953
}
5054

test/specs/mount.spec.js

+21
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,27 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => {
452452
expect(wrapper.html()).to.equal('<div>composition api</div>')
453453
})
454454

455+
it('supports components returning render function from setup as stubs', () => {
456+
const localVue = createLocalVue()
457+
localVue.use(CompositionAPI)
458+
const Parent = {
459+
setup(props, { slots }) {
460+
return () => createElement('div', slots.default())
461+
}
462+
}
463+
const Child = {
464+
setup() {
465+
return () => createElement('div', 'child')
466+
}
467+
}
468+
const wrapper = mount(Parent, {
469+
localVue,
470+
stubs: { child: Child },
471+
slots: { default: [`<child />`] }
472+
})
473+
expect(wrapper.html()).to.equal('<div>\n <div>child</div>\n</div>')
474+
})
475+
455476
itDoNotRunIf.skip(
456477
vueVersion >= 2.5,
457478
'throws if component throws during update',

0 commit comments

Comments
 (0)