Browse Source

Allow null context in Script

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
31b59400f8
  1. 2
      src/node_script.cc
  2. 4
      test/simple/test-script-context.js

2
src/node_script.cc

@ -175,7 +175,7 @@ template <node::Script::EvalInputFlags iFlag,
Local<Object> sandbox;
if (cFlag == newContext) {
sandbox = args.Length() > sbIndex ? args[sbIndex]->ToObject() : Object::New();
sandbox = args[sbIndex]->IsObject() ? args[sbIndex]->ToObject() : Object::New();
} else if (cFlag == userContext) {
sandbox = args[sbIndex]->ToObject();
}

4
test/simple/test-script-context.js

@ -19,3 +19,7 @@ script = new Script('foo = 3;');
result = script.runInContext(context);
assert.equal(3, context.foo);
assert.equal('lala', context.thing);
// Issue GH-227:
Script.runInNewContext('', null, 'some.js');

Loading…
Cancel
Save