File tree 2 files changed +34
-0
lines changed
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export function componentFactory (
58
58
const decorators = ( Component as DecoratedClass ) . __decorators__
59
59
if ( decorators ) {
60
60
decorators . forEach ( fn => fn ( options ) )
61
+ delete ( Component as DecoratedClass ) . __decorators__
61
62
}
62
63
63
64
// find super
Original file line number Diff line number Diff line change 1
1
import Component , { createDecorator } from '../lib'
2
2
import { expect } from 'chai'
3
+ import * as td from 'testdouble'
3
4
import Vue , { ComputedOptions } from 'vue'
4
5
5
6
describe ( 'vue-class-component' , ( ) => {
@@ -187,6 +188,38 @@ describe('vue-class-component', () => {
187
188
expect ( a . b ) . to . equal ( 2 )
188
189
} )
189
190
191
+ // #199
192
+ it ( 'should not re-execute super class decortors' , function ( done ) {
193
+ const Watch = ( valueKey : string ) => createDecorator ( ( options , key ) => {
194
+ if ( ! options . watch ) {
195
+ options . watch = { }
196
+ }
197
+ options . watch [ valueKey ] = key
198
+ } )
199
+
200
+ const spy = td . function ( )
201
+
202
+ @Component
203
+ class Base extends Vue {
204
+ count = 0
205
+
206
+ @Watch ( 'count' )
207
+ notify ( ) {
208
+ spy ( )
209
+ }
210
+ }
211
+
212
+ @Component
213
+ class A extends Base { }
214
+
215
+ const vm = new A ( )
216
+ vm . count ++
217
+ vm . $nextTick ( ( ) => {
218
+ td . verify ( spy ( ) , { times : 1 } )
219
+ done ( )
220
+ } )
221
+ } )
222
+
190
223
it ( 'createDecorator' , function ( ) {
191
224
const Prop = createDecorator ( ( options , key ) => {
192
225
// component options should be passed to the callback
You can’t perform that action at this time.
0 commit comments