File tree Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -65,12 +65,14 @@ export function componentFactory (
65
65
const Super = superProto instanceof Vue
66
66
? superProto . constructor as VueClass < Vue >
67
67
: Vue
68
- const Extended = Super . extend ( options ) ;
68
+ const Extended = Super . extend ( options )
69
69
70
- for ( let staticKey in Component ) {
71
- if ( Component . hasOwnProperty ( staticKey ) ) {
72
- Extended [ staticKey ] = Component [ staticKey ] ;
70
+ Object . getOwnPropertyNames ( Component ) . forEach ( key => {
71
+ if ( key !== 'prototype' ) {
72
+ const descriptor = Object . getOwnPropertyDescriptor ( Component , key ) !
73
+ Object . defineProperty ( Extended , key , descriptor )
73
74
}
74
- }
75
- return Extended ;
75
+ } )
76
+
77
+ return Extended
76
78
}
Original file line number Diff line number Diff line change @@ -107,4 +107,18 @@ describe('vue-class-component with Babel', () => {
107
107
const vm = new MyComp ( )
108
108
expect ( vm . test ( ) ) . to . equal ( 'test' )
109
109
} )
110
+
111
+ it ( 'should forward static members' , ( ) => {
112
+ @Component
113
+ class MyComp extends Vue {
114
+ static foo = 'foo'
115
+
116
+ static bar ( ) {
117
+ return 'bar'
118
+ }
119
+ }
120
+
121
+ expect ( MyComp . foo ) . to . equal ( 'foo' )
122
+ expect ( MyComp . bar ( ) ) . to . equal ( 'bar' )
123
+ } )
110
124
} )
Original file line number Diff line number Diff line change @@ -274,13 +274,18 @@ describe('vue-class-component', () => {
274
274
const vm : any = new MyComp ( )
275
275
expect ( vm . test ) . to . equal ( 'foo' )
276
276
} )
277
-
277
+
278
278
it ( 'forwardStatics' , function ( ) {
279
279
@Component
280
280
class MyComp extends Vue {
281
281
static myValue = 52
282
+
283
+ static myFunc ( ) {
284
+ return 42
285
+ }
282
286
}
283
-
284
- expect ( MyComp . myValue ) . to . equal ( 52 ) ;
287
+
288
+ expect ( MyComp . myValue ) . to . equal ( 52 )
289
+ expect ( MyComp . myFunc ( ) ) . to . equal ( 42 )
285
290
} )
286
291
} )
You can’t perform that action at this time.
0 commit comments