diff --git a/src/node/node_function.hpp b/src/node/node_function.hpp index f983ef23..39e90720 100644 --- a/src/node/node_function.hpp +++ b/src/node/node_function.hpp @@ -26,7 +26,9 @@ namespace js { template<> inline v8::Local node::Function::call(v8::Isolate* isolate, const v8::Local &function, const v8::Local &this_object, size_t argc, const v8::Local arguments[]) { Nan::TryCatch trycatch; - auto result = Nan::Call(function, this_object, (int)argc, const_cast*>(arguments)); + + auto recv = this_object.IsEmpty() ? isolate->GetCurrentContext()->Global() : this_object; + auto result = Nan::Call(function, recv, (int)argc, const_cast*>(arguments)); if (trycatch.HasCaught()) { throw node::Exception(isolate, trycatch.Exception());