Skip to content

Add warning about scoped Slot implementation (#1212) #1389

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
Jan 3, 2020
Merged
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
21 changes: 21 additions & 0 deletions docs/api/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ shallowMount(Component, {
})
```

::: warning Root Element required
Due to the internal implementatioj of this feature, the slot content has to return a root element, even though a scoped slot is allowed to return an array of elements.

If you ever need this in a test, the recommended workaround is to wrap the component under test in another component and mount that one:
:::

```javascript
const WrapperComp = {
template: `
<ComponentUnderTest v-slot="props">
<p>Using the {{props.a}}</p>
<p>Using the {{props.a}}</p>
</ComponentUnderTest>
`,
components: {
ComponentUnderTest
}
}
const wrapper = mount(WrapperComp).find(ComponentUnderTest)
```

## stubs

- type: `{ [name: string]: Component | boolean } | Array<string>`
Expand Down