Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-functions to be passed to Rollbar.wrap #17

Merged
merged 1 commit into from
Mar 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,10 @@ Notifier.prototype.scope = _wrapNotifierFn(function(payloadOptions) {
Notifier.prototype.wrap = function(f) {
var _this = this;

if (typeof f !== 'function') {
return f;
}

// If the given function is already a wrapped function, just
// return it instead of wrapping twice
if (f._isWrap) {
Expand Down
4 changes: 4 additions & 0 deletions src/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ Rollbar.prototype.loadFull = function(window, document, immediate, config) {
Rollbar.prototype.wrap = function(f) {
var _this = this;

if (typeof f !== 'function') {
return f;
}

if (f._isWrap) {
return f;
}
Expand Down
5 changes: 5 additions & 0 deletions test/notifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,4 +1475,9 @@ describe("Notifier.wrap()", function() {

done();
});

it("should let non-functions pass through unchanged", function() {
var object = {};
expect(window.Rollbar.wrap(object)).to.be.equal(object);
});
});
7 changes: 7 additions & 0 deletions test/shim.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ describe("window.Rollbar.log/debug/info/warn/warning/error/critical()", function
});
});

describe("window.Rollbar.wrap()", function() {
it("should let non-functions pass through unchanged", function() {
var object = {};
expect(window.Rollbar.wrap(object)).to.be.equal(object);
});
});

describe("window.Rollbar.loadFull()", function() {
var errArgs;

Expand Down