Skip to content

Commit e9f0e6b

Browse files
authored
fix: allow to configure proxied properties in data hook (#184)
This fix allows the users to create property decorators that declare props/methods in Babel.
1 parent 95d9e65 commit e9f0e6b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/data.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export function collectDataFromConstructor (vm: Vue, Component: VueClass<Vue>) {
1919
if (key.charAt(0) !== '_') {
2020
Object.defineProperty(this, key, {
2121
get: () => vm[key],
22-
set: value => vm[key] = value
22+
set: value => vm[key] = value,
23+
configurable: true
2324
})
2425
}
2526
})

test/test-babel.js

+17
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,21 @@ describe('vue-class-component with Babel', () => {
9090
const vm = new MyComp()
9191
expect(vm.test).to.equal('foo')
9292
})
93+
94+
it('should not throw if property decorator declare some methods', () => {
95+
const Test = createDecorator((options, key) => {
96+
if (!options.methods) {
97+
options.methods = {}
98+
}
99+
options.methods[key] = () => 'test'
100+
})
101+
102+
@Component
103+
class MyComp extends Vue {
104+
@Test test
105+
}
106+
107+
const vm = new MyComp()
108+
expect(vm.test()).to.equal('test')
109+
})
93110
})

0 commit comments

Comments
 (0)