From 8a800867fe61e5aa642e1e3da91bb890d07312f7 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 8 Feb 2019 14:45:45 -0500 Subject: [PATCH] fix: new syntax slots without scope should also be exposed on functional slots() --- src/core/vdom/create-functional-component.js | 10 +++++++++- .../component/component-scoped-slot.spec.js | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/core/vdom/create-functional-component.js b/src/core/vdom/create-functional-component.js index 7acd8a9aefe..c6edf65dfe2 100644 --- a/src/core/vdom/create-functional-component.js +++ b/src/core/vdom/create-functional-component.js @@ -49,7 +49,15 @@ export function FunctionalRenderContext ( this.parent = parent this.listeners = data.on || emptyObject this.injections = resolveInject(options.inject, parent) - this.slots = () => this.$slots || (this.$slots = resolveSlots(children, parent)) + this.slots = () => { + if (!this.$slots) { + normalizeScopedSlots( + data.scopedSlots, + this.$slots = resolveSlots(children, parent) + ) + } + return this.$slots + } Object.defineProperty(this, 'scopedSlots', ({ enumerable: true, diff --git a/test/unit/features/component/component-scoped-slot.spec.js b/test/unit/features/component/component-scoped-slot.spec.js index 8e72efd2e7a..3bf91c087c9 100644 --- a/test/unit/features/component/component-scoped-slot.spec.js +++ b/test/unit/features/component/component-scoped-slot.spec.js @@ -1088,4 +1088,19 @@ describe('Component scoped slot', () => { }).$mount() expect(vm.$el.textContent).toBe('') }) + + it('should expose v-slot without scope on ctx.slots() in functional', () => { + const vm = new Vue({ + template: ``, + components: { + foo: { + functional: true, + render(h, ctx) { + return h('div', ctx.slots().default) + } + } + } + }).$mount() + expect(vm.$el.textContent).toBe('hello') + }) })