Skip to content

Commit

Permalink
Only copy ctx properties when context is defined
Browse files Browse the repository at this point in the history
Fixes #12.
  • Loading branch information
TooTallNate committed Feb 20, 2015
1 parent bfd7c5f commit b9c1cc7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ Script.prototype.runInNewContext = function (context) {
var ctx = Script.createContext(context);
var res = this.runInContext(ctx);

forEach(Object_keys(ctx), function (key) {
context[key] = ctx[key];
});
if (context) {
forEach(Object_keys(ctx), function (key) {
context[key] = ctx[key];
});
}

return res;
};
Expand Down

0 comments on commit b9c1cc7

Please # to comment.