diff --git a/src/raven.js b/src/raven.js index b11dd014e460..abb43f3e8203 100644 --- a/src/raven.js +++ b/src/raven.js @@ -178,10 +178,13 @@ var Raven = { } function wrapped() { - var args = [], i = arguments.length; + var args = [], i = arguments.length, + deep = !options || options && options.deep !== false; // Recursively wrap all of a function's arguments that are // functions themselves. - while(i--) args[i] = Raven.wrap(options, arguments[i]); + + while(i--) args[i] = deep ? Raven.wrap(options, arguments[i]) : arguments[i]; + try { /*jshint -W040*/ return func.apply(this, args); diff --git a/test/raven.test.js b/test/raven.test.js index 864ad0062e70..5d99e37dfca5 100644 --- a/test/raven.test.js +++ b/test/raven.test.js @@ -1040,7 +1040,7 @@ describe('Raven (public API)', function() { }); it('should return the result of a wrapped function', function() { - var func = function() { return 'foo' }; + var func = function() { return 'foo'; }; var wrapped = Raven.wrap(func); assert.equal(wrapped(), 'foo'); }); @@ -1063,6 +1063,16 @@ describe('Raven (public API)', function() { assert.isTrue(spy.calledOnce); }); + it('should not wrap function arguments', function() { + var spy = this.sinon.spy(); + var wrapped = Raven.wrap({ deep: false }, function(f) { + assert.isUndefined(f.__raven__); + f(); + }); + wrapped(spy); + assert.isTrue(spy.calledOnce); + }); + it('should maintain the correct scope', function() { var foo = {}; var bar = function() {