diff --git a/src/core/instance/render.js b/src/core/instance/render.js index 15b3ad69f3a..09285ac13ed 100644 --- a/src/core/instance/render.js +++ b/src/core/instance/render.js @@ -23,7 +23,11 @@ export function initRender (vm: Component) { const parentVnode = vm.$vnode = options._parentVnode // the placeholder node in parent tree const renderContext = parentVnode && parentVnode.context vm.$slots = resolveSlots(options._renderChildren, renderContext) - vm.$scopedSlots = emptyObject + vm.$scopedSlots = vm.$options._parentVnode ? normalizeScopedSlots( + vm.$options._parentVnode.data.scopedSlots, + vm.$slots, + vm.$scopedSlots + ) : emptyObject // bind the createElement fn to this instance // so that we get proper render context inside it. // args order: tag, data, children, normalizationType, alwaysNormalize diff --git a/test/unit/features/component/component-scoped-slot.spec.js b/test/unit/features/component/component-scoped-slot.spec.js index 28369814f48..933f43a2c1b 100644 --- a/test/unit/features/component/component-scoped-slot.spec.js +++ b/test/unit/features/component/component-scoped-slot.spec.js @@ -1325,4 +1325,19 @@ describe('Component scoped slot', () => { expect(vm.$el.textContent).toMatch(`1`) }).then(done) }) + + // vm.$scopedSlots shoud not empty in beforeMount, see issue #11714 + it('$scopedSlots shoud not empty in beforeMount', () => { + const vm = new Vue({ + template: `Slot content`, + components: { + foo: { + template: `
`, + beforeMount () { + expect(Object.keys(this.$scopedSlots).length).not.toBe(0) + } + } + } + }).$mount() + }) })