From 245c2d39d6c3021e63eccded0f58ee878091cf62 Mon Sep 17 00:00:00 2001 From: hjkcai Date: Tue, 28 Mar 2017 14:31:47 +0800 Subject: [PATCH 1/3] use class name as vue component's name --- src/component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/component.ts b/src/component.ts index b2cd349..2404e4c 100644 --- a/src/component.ts +++ b/src/component.ts @@ -26,7 +26,7 @@ export function componentFactory ( Component: VueClass, options: ComponentOptions = {} ): VueClass { - options.name = options.name || (Component as any)._componentTag + options.name = options.name || (Component as any)._componentTag || (Component as any).name // prototype props. const proto = Component.prototype Object.getOwnPropertyNames(proto).forEach(function (key) { From 52b937351a9bc312f889d446dbb7e91b1cd63f6e Mon Sep 17 00:00:00 2001 From: hjkcai Date: Tue, 28 Mar 2017 14:53:04 +0800 Subject: [PATCH 2/3] add name tests --- test/test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/test.ts b/test/test.ts index c90f272..bcef77e 100644 --- a/test/test.ts +++ b/test/test.ts @@ -114,6 +114,34 @@ describe('vue-class-component', () => { expect(c.b).to.equal(3) }) + describe('name', () => { + it('via name option', () => { + @Component({ name: 'test' }) + class MyComp extends Vue {} + + const c = new MyComp() + expect(c.$options.name).to.equal('test') + }) + + it('via _componentTag', () => { + @Component + class MyComp extends Vue { + static _componentTag = 'test' + } + + const c = new MyComp() + expect(c.$options.name).to.equal('test') + }) + + it('via class name', () => { + @Component + class MyComp extends Vue {} + + const c = new MyComp() + expect(c.$options.name).to.equal('MyComp') + }) + }) + it('other options', (done) => { let v: number From 25f1ad763e55eb05318d62478925f75a7e215198 Mon Sep 17 00:00:00 2001 From: hjkcai Date: Tue, 28 Mar 2017 14:54:02 +0800 Subject: [PATCH 3/3] fix test error caused by relative path in webpack config Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.output.path: The provided value "./test" is not an absolute path! --- test/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/webpack.config.js b/test/webpack.config.js index 065d223..7bc90ec 100644 --- a/test/webpack.config.js +++ b/test/webpack.config.js @@ -4,7 +4,7 @@ module.exports = { './test/test-babel.js' ], output: { - path: './test', + path: __dirname, filename: 'test.build.js' }, module: {