Skip to content

Commit 5fc1c57

Browse files
committed
fix: pass children to functional component
1 parent 57aca74 commit 5fc1c57

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/lib/create-instance.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export default function createConstructor (
3434
render (h) {
3535
return h(
3636
clonedComponent,
37-
mountingOptions.context || component.FunctionalRenderContext
37+
mountingOptions.context || component.FunctionalRenderContext,
38+
mountingOptions.context && mountingOptions.context.children
3839
)
3940
}
4041
}

test/unit/specs/mount/options/context.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,19 @@ describe('context', () => {
6565
const wrapper = mount(Component)
6666
expect(wrapper.element.textContent).to.equal(defaultValue)
6767
})
68+
69+
it('mounts functional component with a defined context.children', () => {
70+
const Component = {
71+
functional: true,
72+
render: (h, {children}) => {
73+
return h('div', children)
74+
}
75+
}
76+
const wrapper = mount(Component, {
77+
context: {
78+
children: ['hello']
79+
}
80+
})
81+
expect(wrapper.text()).to.equal('hello')
82+
})
6883
})

0 commit comments

Comments
 (0)