Skip to content

Commit

Permalink
addMethod: Prevent unnecessary transferFlags() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Mar 31, 2016
1 parent 218dd94 commit 2fd19ca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/chai/utils/addMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ module.exports = function (ctx, name, method) {
var old_ssfi = flag(this, 'ssfi');
if (old_ssfi && config.includeStack === false)
flag(this, 'ssfi', ctx[name]);

var result = method.apply(this, arguments);
if (result !== undefined)
return result;

var newAssertion = new chai.Assertion();
transferFlags(this, newAssertion);

return result === undefined ? newAssertion: result;
return newAssertion;
};
};

0 comments on commit 2fd19ca

Please sign in to comment.