Repository: vuejs/vue
Pull request: Add slot v-bind warning (fix #6677)

v-bind with not object warning

close #6677 

<!--
Please make sure to read the Pull Request Guidelines:
https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#pull-request-guidelines
-->

<!-- PULL REQUEST TEMPLATE -->
<!-- (Update "[ ]" to "[x]" to check a box) -->

**What kind of change does this PR introduce?** (check at least one)

- [x] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [ ] Other, please describe:

**Does this PR introduce a breaking change?** (check one)

- [ ] Yes
- [x] No

If yes, please describe the impact and migration path for existing applications:

**The PR fulfills these requirements:**

- [x] It's submitted to the `dev` branch for v2.x (or to a previous version branch), _not_ the `master` branch
- [x] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
- [x] All tests are passing: https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#development-setup
- [x] New/updated tests are included

If adding a **new feature**, the PR's description includes:
- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

**Other information:**


Changed files:
filename: src/core/instance/render-helpers/render-slot.js
patch: @@ -1,6 +1,6 @@
 /* @flow */
 
-import { extend, warn } from 'core/util/index'
+import { extend, warn, isObject } from 'core/util/index'
 
 /**
  * Runtime helper for rendering <slot>
@@ -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

filename: test/unit/features/component/component-scoped-slot.spec.js
patch: @@ -93,6 +93,60 @@ describe('Component scoped slot', () => {
     }).then(done)
   })
 
+  it('should warn when using v-bind with no object', () => {
+    new Vue({
+      template: `
+        <test ref="test">
+          <template scope="props">
+          </template>
+        </test>
+      `,
+      components: {
+        test: {
+          data () {
+            return {
+              text: 'some text'
+            }
+          },
+          template: `
+            <div>
+              <slot v-bind="text"></slot>
+            </div>
+          `
+        }
+      }
+    }).$mount()
+    expect('slot v-bind without argument expects an Object').toHaveBeenWarned()
+  })
+
+  it('should not warn when using v-bind with object', () => {
+    new Vue({
+      template: `
+        <test ref="test">
+          <template scope="props">
+          </template>
+        </test>
+      `,
+      components: {
+        test: {
+          data () {
+            return {
+              foo: {
+                text: 'some text'
+              }
+            }
+          },
+          template: `
+            <div>
+              <slot v-bind="foo"></slot>
+            </div>
+          `
+        }
+      }
+    }).$mount()
+    expect('slot v-bind without argument expects an Object').not.toHaveBeenWarned()
+  })
+
   it('named scoped slot', done => {
     const vm = new Vue({
       template: `