Skip to content

Commit 9419e48

Browse files
committed
Merge pull request #182 from Stereobit/master
add option to prevent wrapping also the functions arguments
2 parents 1c48231 + e8522b6 commit 9419e48

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/raven.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,13 @@ var Raven = {
178178
}
179179

180180
function wrapped() {
181-
var args = [], i = arguments.length;
181+
var args = [], i = arguments.length,
182+
deep = !options || options && options.deep !== false;
182183
// Recursively wrap all of a function's arguments that are
183184
// functions themselves.
184-
while(i--) args[i] = Raven.wrap(options, arguments[i]);
185+
186+
while(i--) args[i] = deep ? Raven.wrap(options, arguments[i]) : arguments[i];
187+
185188
try {
186189
/*jshint -W040*/
187190
return func.apply(this, args);

test/raven.test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ describe('Raven (public API)', function() {
10401040
});
10411041

10421042
it('should return the result of a wrapped function', function() {
1043-
var func = function() { return 'foo' };
1043+
var func = function() { return 'foo'; };
10441044
var wrapped = Raven.wrap(func);
10451045
assert.equal(wrapped(), 'foo');
10461046
});
@@ -1063,6 +1063,16 @@ describe('Raven (public API)', function() {
10631063
assert.isTrue(spy.calledOnce);
10641064
});
10651065

1066+
it('should not wrap function arguments', function() {
1067+
var spy = this.sinon.spy();
1068+
var wrapped = Raven.wrap({ deep: false }, function(f) {
1069+
assert.isUndefined(f.__raven__);
1070+
f();
1071+
});
1072+
wrapped(spy);
1073+
assert.isTrue(spy.calledOnce);
1074+
});
1075+
10661076
it('should maintain the correct scope', function() {
10671077
var foo = {};
10681078
var bar = function() {

0 commit comments

Comments
 (0)