From fbcff159ac7a01b2539ac3da3d03edb00160c9d1 Mon Sep 17 00:00:00 2001 From: ktsn Date: Sat, 4 Nov 2017 00:47:41 +0900 Subject: [PATCH] fix: allow to configure proxied properties in data hook This fix allows the users to create property decorators that declare props/methods in Babel. --- src/data.ts | 3 ++- test/test-babel.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/data.ts b/src/data.ts index 91e641a..259df50 100644 --- a/src/data.ts +++ b/src/data.ts @@ -19,7 +19,8 @@ export function collectDataFromConstructor (vm: Vue, Component: VueClass) { if (key.charAt(0) !== '_') { Object.defineProperty(this, key, { get: () => vm[key], - set: value => vm[key] = value + set: value => vm[key] = value, + configurable: true }) } }) diff --git a/test/test-babel.js b/test/test-babel.js index 73cbd7f..b03c3df 100644 --- a/test/test-babel.js +++ b/test/test-babel.js @@ -90,4 +90,21 @@ describe('vue-class-component with Babel', () => { const vm = new MyComp() expect(vm.test).to.equal('foo') }) + + it('should not throw if property decorator declare some methods', () => { + const Test = createDecorator((options, key) => { + if (!options.methods) { + options.methods = {} + } + options.methods[key] = () => 'test' + }) + + @Component + class MyComp extends Vue { + @Test test + } + + const vm = new MyComp() + expect(vm.test()).to.equal('test') + }) })