Bläddra i källkod

fix: allow passing multiple arguments to scoped slot

fix #9468

Note: the usage is NOT recommended
Evan You 7 år sedan
förälder
incheckning
e7d49cdcf2

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

@@ -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)

+ 16 - 0
test/unit/features/component/component-scoped-slot.spec.js

@@ -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')
+  })
 })