Skip to content

Commit

Permalink
fix: allow passing multiple arguments to scoped slot
Browse files Browse the repository at this point in the history
fix #9468

Note: the usage is NOT recommended
  • Loading branch information
yyx990803 committed Feb 11, 2019
1 parent 060686d commit e7d49cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/vdom/helpers/normalize-scoped-slots.js
Expand Up @@ -48,8 +48,8 @@ export function normalizeScopedSlots (
}

function normalizeScopedSlot(normalSlots, key, fn) {
const normalized = scope => {
let res = fn(scope || {})
const normalized = function () {
let res = arguments.length ? fn.apply(null, arguments) : fn({})
res = res && typeof res === 'object' && !Array.isArray(res)
? [res] // single vnode
: normalizeChildren(res)
Expand Down
16 changes: 16 additions & 0 deletions test/unit/features/component/component-scoped-slot.spec.js
Expand Up @@ -1128,4 +1128,20 @@ describe('Component scoped slot', () => {
expect(vm.$el.textContent).toBe(`baz bar`)
}).then(done)
})

// #9468
it('should support passing multiple args to scoped slot function', () => {
const foo = {
render() {
return this.$scopedSlots.default('foo', 'bar')
}
}

const vm = new Vue({
template: `<foo v-slot="foo, bar">{{ foo }} {{ bar }}</foo>`,
components: { foo }
}).$mount()

expect(vm.$el.textContent).toBe('foo bar')
})
})

0 comments on commit e7d49cd

Please sign in to comment.