Skip to content

Commit 99c79f8

Browse files
committed
doc: call js function in null context
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 <rod@vagg.org> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
1 parent 55abf34 commit 99c79f8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

doc/api/addons.markdown

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ there. Here's `addon.cc`:
215215
using v8::HandleScope;
216216
using v8::Isolate;
217217
using v8::Local;
218+
using v8::Null;
218219
using v8::Object;
219220
using v8::String;
220221
using v8::Value;
@@ -224,7 +225,7 @@ there. Here's `addon.cc`:
224225
Local<Function> cb = Local<Function>::Cast(args[0]);
225226
const unsigned argc = 1;
226227
Local<Value> argv[argc] = { String::NewFromUtf8(isolate, "hello world") };
227-
cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
228+
cb->Call(Null(isolate), argc, argv);
228229
}
229230

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

0 commit comments

Comments
 (0)