Repository: vuejs/vue
Pull request: Fix 7191 - data arg merge

Fix #7191 

<!--
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/util/options.js
patch: @@ -85,18 +85,18 @@ export function mergeDataOrFn (
     // it has to be a function to pass previous merges.
     return function mergedDataFn () {
       return mergeData(
-        typeof childVal === 'function' ? childVal.call(this) : childVal,
-        typeof parentVal === 'function' ? parentVal.call(this) : parentVal
+        typeof childVal === 'function' ? childVal.call(this, this) : childVal,
+        typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
       )
     }
   } else {
     return function mergedInstanceDataFn () {
       // instance merge
       const instanceData = typeof childVal === 'function'
-        ? childVal.call(vm)
+        ? childVal.call(vm, vm)
         : childVal
       const defaultData = typeof parentVal === 'function'
-        ? parentVal.call(vm)
+        ? parentVal.call(vm, vm)
         : parentVal
       if (instanceData) {
         return mergeData(instanceData, defaultData)

filename: test/unit/features/options/data.spec.js
patch: @@ -107,7 +107,7 @@ describe('Options data', () => {
     expect(vm.a).toBe(1)
   })
 
-  it('should called with this', () => {
+  it('should be called with this', () => {
     const vm = new Vue({
       template: '<div><child></child></div>',
       provide: { foo: 1 },
@@ -123,4 +123,32 @@ describe('Options data', () => {
     }).$mount()
     expect(vm.$el.innerHTML).toBe('<span>foo:1</span>')
   })
+
+  it('should be called with vm as first argument when merged', () => {
+    const superComponent = {
+      data: ({ foo }) => ({ ext: 'ext:' + foo })
+    }
+    const mixins = [
+      {
+        data: ({ foo }) => ({ mixin1: 'm1:' + foo })
+      },
+      {
+        data: ({ foo }) => ({ mixin2: 'm2:' + foo })
+      }
+    ]
+    const vm = new Vue({
+      template: '<div><child></child></div>',
+      provide: { foo: 1 },
+      components: {
+        child: {
+          extends: superComponent,
+          mixins,
+          template: '<span>{{bar}}-{{ext}}-{{mixin1}}-{{mixin2}}</span>',
+          inject: ['foo'],
+          data: ({ foo }) => ({ bar: 'foo:' + foo })
+        }
+      }
+    }).$mount()
+    expect(vm.$el.innerHTML).toBe('<span>foo:1-ext:1-m1:1-m2:1</span>')
+  })
 })