diff --git a/packages/create-instance/create-functional-component.js b/packages/create-instance/create-functional-component.js
index 8eb9b88cc..61d07aaf9 100644
--- a/packages/create-instance/create-functional-component.js
+++ b/packages/create-instance/create-functional-component.js
@@ -3,6 +3,7 @@
import { throwError } from 'shared/util'
import { validateSlots } from './validate-slots'
import { createSlotVNodes } from './create-slot-vnodes'
+import createScopedSlots from './create-scoped-slots'
export default function createFunctionalComponent (
component: Component,
@@ -15,11 +16,15 @@ export default function createFunctionalComponent (
validateSlots(mountingOptions.slots)
}
+ const data = mountingOptions.context ||
+ component.FunctionalRenderContext || {}
+ data.scopedSlots = createScopedSlots(mountingOptions.scopedSlots)
+
return {
render (h: Function) {
return h(
component,
- mountingOptions.context || component.FunctionalRenderContext,
+ data,
(mountingOptions.context &&
mountingOptions.context.children &&
mountingOptions.context.children.map(
diff --git a/test/specs/mounting-options/scopedSlots.spec.js b/test/specs/mounting-options/scopedSlots.spec.js
index b1b651141..b4392dc32 100644
--- a/test/specs/mounting-options/scopedSlots.spec.js
+++ b/test/specs/mounting-options/scopedSlots.spec.js
@@ -88,6 +88,50 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => {
}
)
+ itDoNotRunIf(
+ vueVersion < 2.5,
+ 'mounts component scoped slots in render function which exists in functional component',
+ () => {
+ const destructuringWrapper = mountingMethod(
+ {
+ functional: true,
+ render: function (createElement, context) {
+ return context.data.scopedSlots.default({
+ index: 1,
+ item: 'foo'
+ })
+ }
+ },
+ {
+ scopedSlots: {
+ default:
+ ' {{index}},{{item}}
1,foo
') + + const notDestructuringWrapper = mountingMethod( + { + functional: true, + render: function (createElement, context) { + return context.data.scopedSlots.named({ + index: 1, + item: 'foo' + }) + } + }, + { + scopedSlots: { + named: + '{{foo.index}},{{foo.item}}
' + } + } + ) + expect(notDestructuringWrapper.html()).to.equal('1,foo
') + } + ) + itDoNotRunIf( vueVersion < 2.5, 'mounts component scoped slots',