diff --git a/src/shared/getComponentOption.js b/src/shared/getComponentOption.js index 172fdb0..da150dc 100644 --- a/src/shared/getComponentOption.js +++ b/src/shared/getComponentOption.js @@ -1,4 +1,4 @@ -import { isFunction, isObject } from '../utils/is-type' +import { isObject } from '../utils/is-type' import { defaultInfo } from './constants' import { merge } from './merge' import { inMetaInfoBranch } from './meta-helpers' diff --git a/test/components/changed.vue b/test/components/changed.vue index 4d2c02d..5bbf3cf 100644 --- a/test/components/changed.vue +++ b/test/components/changed.vue @@ -18,17 +18,13 @@ export default { }, metaInfo() { return { - changed: this._changed + changed: this.changed.bind(this) } }, data() { return { - childVisible: false, - _changed: () => {} + childVisible: false } - }, - mounted() { - this._changed = this.changed.bind(this) - } +f } } diff --git a/test/unit/getComponentOptions.test.js b/test/unit/getComponentOptions.test.js index fe1dc38..a4e73e4 100644 --- a/test/unit/getComponentOptions.test.js +++ b/test/unit/getComponentOptions.test.js @@ -20,13 +20,19 @@ describe('getComponentOption', () => { expect(mergedOption.foo).toEqual('bar') }) - test('calls a function option, injecting the component as context', () => { + test('calls a function as computed prop, injecting the component as context', () => { const component = new Vue({ name: 'Foobar', someFunc () { - return { opt: this.$options.name } + return { opt: this.name } + }, + computed: { + $metaInfo () { + return this.$options.someFunc() + } } }) + const mergedOption = getComponentOption({ keyName: 'someFunc' }, component) // TODO: Should this be foobar or Foobar expect(mergedOption.opt).toBeDefined()