Skip to content

feat: render all children in auto stubs #931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/shared/stub-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function createBlankStub (
...this.$props
}
},
context ? context.children : this.$slots.default
context ? context.children : this.$options._renderChildren
)
}
}
Expand Down
19 changes: 19 additions & 0 deletions test/specs/shallow-mount.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
expect(wrapper.html()).to.equal('<child-stub>Hello</child-stub>')
})

it('renders named slots', () => {
const localVue = createLocalVue()
localVue.component('child', {
template: '<div />'
})
const TestComponent = {
template: `
<child>
<p slot="header">Hello</p>
<p slot="footer">World</p>
</child>
`
}
const wrapper = shallowMount(TestComponent, {
localVue
})
expect(wrapper.html()).to.equal('<child-stub><p>Hello</p> <p>World</p></child-stub>')
})

it('renders no children if none supplied', () => {
const TestComponent = {
template: '<child />',
Expand Down