File tree 2 files changed +28
-7
lines changed
2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -156,14 +156,23 @@ var Raven = {
156
156
options = undefined ;
157
157
}
158
158
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 ] ;
165
172
}
166
- } ;
173
+ }
174
+
175
+ return wrappedFunction ;
167
176
} ,
168
177
169
178
/*
Original file line number Diff line number Diff line change @@ -873,6 +873,18 @@ describe('Raven (public API)', function() {
873
873
wrapped ( ) ;
874
874
assert . isTrue ( spy . calledOnce ) ;
875
875
} ) ;
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
+ } ) ;
876
888
} ) ;
877
889
878
890
describe ( '.context' , function ( ) {
You can’t perform that action at this time.
0 commit comments