mirror of
https://github.com/vuejs/vue.git
synced 2024-11-22 04:39:46 +00:00
fix: new syntax slots without scope should also be exposed on functional slots()
This commit is contained in:
parent
099f3ba600
commit
8a800867fe
@ -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,
|
||||
|
@ -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: `<foo><template v-slot>hello</template></foo>`,
|
||||
components: {
|
||||
foo: {
|
||||
functional: true,
|
||||
render(h, ctx) {
|
||||
return h('div', ctx.slots().default)
|
||||
}
|
||||
}
|
||||
}
|
||||
}).$mount()
|
||||
expect(vm.$el.textContent).toBe('hello')
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user