Skip to content

Commit 6e3e4e5

Browse files
authored
fix(validators): support components returning render function from setup (#1600)
fix #1596
1 parent 9699877 commit 6e3e4e5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-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

+25
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,31 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => {
437437
expect(wrapper.html()).toEqual('<div>msg</div>')
438438
})
439439

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

0 commit comments

Comments
 (0)