Skip to content

Commit eb70dde

Browse files
author
kingwl
committed
fix slot resolved incorrect with abstract component (fix vuejs#5888)
1 parent 080c387 commit eb70dde

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/core/vdom/create-component.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ export function createComponent (
169169

170170
if (isTrue(Ctor.options.abstract)) {
171171
// abstract components do not keep anything
172-
// other than props & listeners
172+
// other than props & listeners & slot
173+
174+
// work around flow
175+
const slot = data.slot
173176
data = {}
177+
if (slot) {
178+
data.slot = slot
179+
}
174180
}
175181

176182
// merge component management hooks onto the placeholder node

test/unit/features/component/component-slot.spec.js

+25
Original file line numberDiff line numberDiff line change
@@ -660,4 +660,29 @@ describe('Component slot', () => {
660660
expect(vm.$el.querySelector('input').value).toBe('b')
661661
}).then(done)
662662
})
663+
664+
// Github issue #5888
665+
it('should resolve correctly slot with keep-alive', () => {
666+
const vm = new Vue({
667+
template: `
668+
<div>
669+
<container>
670+
<keep-alive slot="foo">
671+
<child></child>
672+
</keep-alive>
673+
</container>
674+
</div>
675+
`,
676+
components: {
677+
container: {
678+
template:
679+
'<div><slot>default</slot><slot name="foo">named</slot></div>'
680+
},
681+
child: {
682+
template: '<span>foo</span>'
683+
}
684+
}
685+
}).$mount()
686+
expect(vm.$el.innerHTML).toBe('<div>default<span>foo</span></div>')
687+
})
663688
})

0 commit comments

Comments
 (0)