File tree Expand file tree Collapse file tree 2 files changed +28
-7
lines changed
Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -156,14 +156,23 @@ var Raven = {
156156 options = undefined ;
157157 }
158158
159- return function ( ) {
160- try {
161- return func . apply ( this , arguments ) ;
162- } catch ( e ) {
163- Raven . captureException ( e , options ) ;
164- throw e ;
159+ var property ,
160+ wrappedFunction = function ( ) {
161+ try {
162+ func . apply ( this , arguments ) ;
163+ } catch ( e ) {
164+ Raven . captureException ( e , options ) ;
165+ throw e ;
166+ }
167+ } ;
168+
169+ for ( property in func ) {
170+ if ( func . hasOwnProperty ( property ) ) {
171+ wrappedFunction [ property ] = func [ property ] ;
165172 }
166- } ;
173+ }
174+
175+ return wrappedFunction ;
167176 } ,
168177
169178 /*
Original file line number Diff line number Diff line change @@ -873,6 +873,18 @@ describe('Raven (public API)', function() {
873873 wrapped ( ) ;
874874 assert . isTrue ( spy . calledOnce ) ;
875875 } ) ;
876+ it ( 'should copy property when wrapping function' , function ( ) {
877+ var func = function ( ) { } ;
878+ func . test = true ;
879+ var wrapped = Raven . wrap ( func ) ;
880+ assert . isTrue ( wrapped . test ) ;
881+ } ) ;
882+ it ( 'should not copy prototype property when wrapping function' , function ( ) {
883+ var func = function ( ) { } ;
884+ func . prototype . test = true ;
885+ var wrapped = Raven . wrap ( func ) ;
886+ assert . isUndefined ( new wrapped ( ) . test ) ;
887+ } ) ;
876888 } ) ;
877889
878890 describe ( '.context' , function ( ) {
You can’t perform that action at this time.
0 commit comments