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 (
6565 const Super = superProto instanceof Vue
6666 ? superProto . constructor as VueClass < Vue >
6767 : Vue
68- const Extended = Super . extend ( options ) ;
68+ const Extended = Super . extend ( options )
6969
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 )
7374 }
74- }
75- return Extended ;
75+ } )
76+
77+ return Extended
7678}
Original file line number Diff line number Diff line change @@ -107,4 +107,18 @@ describe('vue-class-component with Babel', () => {
107107 const vm = new MyComp ( )
108108 expect ( vm . test ( ) ) . to . equal ( 'test' )
109109 } )
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+ } )
110124} )
Original file line number Diff line number Diff line change @@ -274,13 +274,18 @@ describe('vue-class-component', () => {
274274 const vm : any = new MyComp ( )
275275 expect ( vm . test ) . to . equal ( 'foo' )
276276 } )
277-
277+
278278 it ( 'forwardStatics' , function ( ) {
279279 @Component
280280 class MyComp extends Vue {
281281 static myValue = 52
282+
283+ static myFunc ( ) {
284+ return 42
285+ }
282286 }
283-
284- expect ( MyComp . myValue ) . to . equal ( 52 ) ;
287+
288+ expect ( MyComp . myValue ) . to . equal ( 52 )
289+ expect ( MyComp . myFunc ( ) ) . to . equal ( 42 )
285290 } )
286291} )
You can’t perform that action at this time.
0 commit comments