From eb70dde782693c255cfb4df67851009ddb50faae Mon Sep 17 00:00:00 2001 From: kingwl Date: Fri, 16 Jun 2017 10:27:37 +0800 Subject: [PATCH] fix slot resolved incorrect with abstract component (fix #5888) --- src/core/vdom/create-component.js | 8 +++++- .../features/component/component-slot.spec.js | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/core/vdom/create-component.js b/src/core/vdom/create-component.js index 954adab255b..0553706c640 100644 --- a/src/core/vdom/create-component.js +++ b/src/core/vdom/create-component.js @@ -169,8 +169,14 @@ export function createComponent ( if (isTrue(Ctor.options.abstract)) { // abstract components do not keep anything - // other than props & listeners + // other than props & listeners & slot + + // work around flow + const slot = data.slot data = {} + if (slot) { + data.slot = slot + } } // merge component management hooks onto the placeholder node diff --git a/test/unit/features/component/component-slot.spec.js b/test/unit/features/component/component-slot.spec.js index 0b9c4928d28..6eb3927ef04 100644 --- a/test/unit/features/component/component-slot.spec.js +++ b/test/unit/features/component/component-slot.spec.js @@ -660,4 +660,29 @@ describe('Component slot', () => { expect(vm.$el.querySelector('input').value).toBe('b') }).then(done) }) + + // Github issue #5888 + it('should resolve correctly slot with keep-alive', () => { + const vm = new Vue({ + template: ` +
+ + + + + +
+ `, + components: { + container: { + template: + '
defaultnamed
' + }, + child: { + template: 'foo' + } + } + }).$mount() + expect(vm.$el.innerHTML).toBe('
defaultfoo
') + }) })