Browse files

runInNewContext should modify passed object.

  • Loading branch information...
1 parent e6bbfb4 commit 5beb27752e8b2ce45ce3c4f16247fcdf71426d27 @pluma pluma committed with Jan 18, 2014
Showing with 8 additions and 1 deletion.
  1. +8 −1 index.js
View
9 index.js
@@ -69,7 +69,14 @@ Script.prototype.runInThisContext = function () {
};
Script.prototype.runInNewContext = function (context) {
- return this.runInContext(Script.createContext(context));
+ var ctx = Script.createContext(context);
+ var res = this.runInContext(ctx);
+
+ forEach(Object_keys(ctx), function (key) {
+ context[key] = ctx[key];
+ });
+
+ return res;
};
forEach(Object_keys(Script.prototype), function (name) {

0 comments on commit 5beb277

Please sign in to comment.