diff --git a/src/core/instance/render-helpers/render-slot.js b/src/core/instance/render-helpers/render-slot.js index 3eaff882522..1a194c579e3 100644 --- a/src/core/instance/render-helpers/render-slot.js +++ b/src/core/instance/render-helpers/render-slot.js @@ -1,6 +1,6 @@ /* @flow */ -import { extend, warn } from 'core/util/index' +import { extend, warn, isObject } from 'core/util/index' /** * Runtime helper for rendering @@ -15,6 +15,12 @@ export function renderSlot ( if (scopedSlotFn) { // scoped slot props = props || {} if (bindObject) { + if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) { + warn( + 'slot v-bind without argument expects an Object', + this + ) + } props = extend(extend({}, bindObject), props) } return scopedSlotFn(props) || fallback diff --git a/test/unit/features/component/component-scoped-slot.spec.js b/test/unit/features/component/component-scoped-slot.spec.js index f4661fde403..8c17befde28 100644 --- a/test/unit/features/component/component-scoped-slot.spec.js +++ b/test/unit/features/component/component-scoped-slot.spec.js @@ -93,6 +93,60 @@ describe('Component scoped slot', () => { }).then(done) }) + it('should warn when using v-bind with no object', () => { + new Vue({ + template: ` + + + + `, + components: { + test: { + data () { + return { + text: 'some text' + } + }, + template: ` +
+ +
+ ` + } + } + }).$mount() + expect('slot v-bind without argument expects an Object').toHaveBeenWarned() + }) + + it('should not warn when using v-bind with object', () => { + new Vue({ + template: ` + + + + `, + components: { + test: { + data () { + return { + foo: { + text: 'some text' + } + } + }, + template: ` +
+ +
+ ` + } + } + }).$mount() + expect('slot v-bind without argument expects an Object').not.toHaveBeenWarned() + }) + it('named scoped slot', done => { const vm = new Vue({ template: `