Skip to content

Commit

Permalink
doc: call js function in null context
Browse files Browse the repository at this point in the history
It's good practice now to call JS functions that don't execute in a
specific scope with v8::Null() as the receiver.  Update the addons
documentation.

PR-URL: #1125
Reviewed-By: Rod Vagg <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
  • Loading branch information
bnoordhuis committed Mar 21, 2015
1 parent 55abf34 commit 99c79f8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/api/addons.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ there. Here's `addon.cc`:
using v8::HandleScope;
using v8::Isolate;
using v8::Local;
using v8::Null;
using v8::Object;
using v8::String;
using v8::Value;
Expand All @@ -224,7 +225,7 @@ there. Here's `addon.cc`:
Local<Function> cb = Local<Function>::Cast(args[0]);
const unsigned argc = 1;
Local<Value> argv[argc] = { String::NewFromUtf8(isolate, "hello world") };
cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
cb->Call(Null(isolate), argc, argv);
}

void Init(Local<Object> exports, Local<Object> module) {
Expand Down

0 comments on commit 99c79f8

Please sign in to comment.