Skip to content

Commit 1ad731e

Browse files
authored
feat: render slots by default (#782)
breaking change
1 parent d596dbd commit 1ad731e

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

Diff for: packages/shared/stub-components.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ function createBlankStub (originalComponent: Component, name: string) {
100100
return {
101101
...getCoreProperties(componentOptions),
102102
render (h) {
103-
return h(tagName)
103+
return h(
104+
tagName,
105+
!componentOptions.functional && this.$slots.default
106+
)
104107
}
105108
}
106109
}

Diff for: test/specs/mounting-options/stubs.spec.js

+24-4
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,25 @@ describeWithMountingMethods('options.stub', mountingMethod => {
174174
expect(HTML).not.to.contain('<span>')
175175
})
176176

177+
it('renders slot content in stubs', () => {
178+
const TestComponent = {
179+
template: `
180+
<div>
181+
<stub-with-child>
182+
<child-component />
183+
</stub-with-child>
184+
</div>
185+
`
186+
}
187+
const wrapper = mountingMethod(TestComponent, {
188+
stubs: ['child-component', 'stub-with-child']
189+
})
190+
const HTML = mountingMethod.name === 'renderToString'
191+
? wrapper
192+
: wrapper.html()
193+
expect(HTML).to.contain('<child-component-stub>')
194+
})
195+
177196
itDoNotRunIf(
178197
mountingMethod.name === 'renderToString',
179198
'stubs components with dummy which has name when passed a boolean', () => {
@@ -320,19 +339,20 @@ describeWithMountingMethods('options.stub', mountingMethod => {
320339
'stubs on child components',
321340
() => {
322341
const TestComponent = {
323-
template: '<transition><span /></transition>'
342+
template: '<transition></transition>'
324343
}
325-
326344
const wrapper = mountingMethod(
327345
{
328346
components: { 'test-component': TestComponent },
329347
template: '<test-component />'
330348
},
331349
{
332-
stubs: ['transition']
350+
stubs: {
351+
'transition': 'time'
352+
}
333353
}
334354
)
335-
expect(wrapper.find('span').exists()).to.equal(false)
355+
expect(wrapper.find('time').exists()).to.equal(false)
336356
}
337357
)
338358

0 commit comments

Comments
 (0)