Skip to content

Commit 7b267b0

Browse files
authored
Merge pull request #1389 from vuejs/scopedslots-tip
Add warning about scoped Slot implementation (#1212)
2 parents 916b07f + f2220ee commit 7b267b0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: docs/api/options.md

+21
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,27 @@ shallowMount(Component, {
147147
})
148148
```
149149

150+
::: warning Root Element required
151+
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.
152+
153+
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:
154+
:::
155+
156+
```javascript
157+
const WrapperComp = {
158+
template: `
159+
<ComponentUnderTest v-slot="props">
160+
<p>Using the {{props.a}}</p>
161+
<p>Using the {{props.a}}</p>
162+
</ComponentUnderTest>
163+
`,
164+
components: {
165+
ComponentUnderTest
166+
}
167+
}
168+
const wrapper = mount(WrapperComp).find(ComponentUnderTest)
169+
```
170+
150171
## stubs
151172

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

0 commit comments

Comments
 (0)