Skip to content

Commit 876ee19

Browse files
committed
fix(validators): support components returning render function from setup
fix #1596
1 parent f78f817 commit 876ee19

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
@@ -437,6 +437,27 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => {
437437
expect(wrapper.html()).toEqual('<div>msg</div>')
438438
})
439439

440+
it('supports components returning render function from setup as stubs', () => {
441+
const localVue = createLocalVue()
442+
localVue.use(CompositionAPI)
443+
const Parent = {
444+
setup(props, { slots }) {
445+
return () => createElement('div', slots.default())
446+
}
447+
}
448+
const Child = {
449+
setup() {
450+
return () => createElement('div', 'child')
451+
}
452+
}
453+
const wrapper = mount(Parent, {
454+
localVue,
455+
stubs: { child: Child },
456+
slots: { default: [`<child />`] }
457+
})
458+
expect(wrapper.html()).toEqual('<div>\n <div>child</div>\n</div>')
459+
})
460+
440461
itDoNotRunIf.skip(
441462
vueVersion >= 2.5,
442463
'throws if component throws during update',

0 commit comments

Comments
 (0)