Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Conversation

jalexanderfox
Copy link

object literal stored in sandbox was throwing an error, vm.createContext(sandbox); returns a contextifiedSandbox which was not being used in script.runInContext(sandbox);

This modification fixes the example by creating the context and passing it as a parameter to script.runInContext

object literal stored in sandbox was throwing an error, vm.createContext(sandbox); returns a contextifiedSandbox which was not being used in script.runInContext(sandbox);

This modification fixes the example by creating the context and passing it as a parameter to script.runInContext
@jasnell
Copy link
Member

jasnell commented Jun 29, 2015

This is not necessary. The contextifiedSandbox returned by the createContext method is the exact same sandbox object that is passed in. You can verify that by doing a quick:

var vm = require('vm');
var sandbox = {};
console.log(sandbox === vm.createContext(sandbox));

@jasnell jasnell closed this Jun 29, 2015
@jalexanderfox
Copy link
Author

Same as #25566, I was using an old version of node 0.10.35_2, my apologies.

@jalexanderfox jalexanderfox deleted the patch-2 branch June 29, 2015 17:22
@jasnell
Copy link
Member

jasnell commented Jun 29, 2015

No need to apologize! PR's are always welcome!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants