File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export function componentFactory (
5858 const decorators = ( Component as DecoratedClass ) . __decorators__
5959 if ( decorators ) {
6060 decorators . forEach ( fn => fn ( options ) )
61+ delete ( Component as DecoratedClass ) . __decorators__
6162 }
6263
6364 // find super
Original file line number Diff line number Diff line change 11import Component , { createDecorator } from '../lib'
22import { expect } from 'chai'
3+ import * as td from 'testdouble'
34import Vue , { ComputedOptions } from 'vue'
45
56describe ( 'vue-class-component' , ( ) => {
@@ -187,6 +188,38 @@ describe('vue-class-component', () => {
187188 expect ( a . b ) . to . equal ( 2 )
188189 } )
189190
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+
190223 it ( 'createDecorator' , function ( ) {
191224 const Prop = createDecorator ( ( options , key ) => {
192225 // component options should be passed to the callback
You can’t perform that action at this time.
0 commit comments