Skip to content

Commit e7d49cd

Browse files
committed
fix: allow passing multiple arguments to scoped slot
fix #9468 Note: the usage is NOT recommended
1 parent 060686d commit e7d49cd

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/core/vdom/helpers/normalize-scoped-slots.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export function normalizeScopedSlots (
4848
}
4949

5050
function normalizeScopedSlot(normalSlots, key, fn) {
51-
const normalized = scope => {
52-
let res = fn(scope || {})
51+
const normalized = function () {
52+
let res = arguments.length ? fn.apply(null, arguments) : fn({})
5353
res = res && typeof res === 'object' && !Array.isArray(res)
5454
? [res] // single vnode
5555
: normalizeChildren(res)

test/unit/features/component/component-scoped-slot.spec.js

+16
Original file line numberDiff line numberDiff line change
@@ -1128,4 +1128,20 @@ describe('Component scoped slot', () => {
11281128
expect(vm.$el.textContent).toBe(`baz bar`)
11291129
}).then(done)
11301130
})
1131+
1132+
// #9468
1133+
it('should support passing multiple args to scoped slot function', () => {
1134+
const foo = {
1135+
render() {
1136+
return this.$scopedSlots.default('foo', 'bar')
1137+
}
1138+
}
1139+
1140+
const vm = new Vue({
1141+
template: `<foo v-slot="foo, bar">{{ foo }} {{ bar }}</foo>`,
1142+
components: { foo }
1143+
}).$mount()
1144+
1145+
expect(vm.$el.textContent).toBe('foo bar')
1146+
})
11311147
})

0 commit comments

Comments
 (0)