Feature - Bring back node support (#217)
This PR brings back support for node.js later versions, as well as actually making it work. Maps now render, properly, using node v10, v12, and v16.
This commit is contained in:
committed by
GitHub
parent
b7a42e9974
commit
cfcbc62fad
@@ -26,7 +26,8 @@ NodeRequest::~NodeRequest() {
|
||||
|
||||
Nan::Persistent<v8::Function> NodeRequest::constructor;
|
||||
|
||||
void NodeRequest::Init() {
|
||||
void NodeRequest::Init(v8::Local<v8::Object> target) {
|
||||
v8::Local<v8::Context> context = target->CreationContext();
|
||||
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
||||
|
||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
@@ -34,7 +35,7 @@ void NodeRequest::Init() {
|
||||
|
||||
Nan::SetPrototypeMethod(tpl, "respond", HandleCallback);
|
||||
|
||||
constructor.Reset(tpl->GetFunction());
|
||||
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
|
||||
}
|
||||
|
||||
void NodeRequest::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
@@ -49,7 +50,12 @@ void NodeRequest::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
Nan::Set(info.This(), Nan::New("url").ToLocalChecked(), info[3]);
|
||||
Nan::Set(info.This(), Nan::New("kind").ToLocalChecked(), info[4]);
|
||||
v8::Local<v8::Value> argv[] = { info.This() };
|
||||
request->asyncResource->runInAsyncScope(Nan::To<v8::Object>(target->handle()->GetInternalField(1)).ToLocalChecked(), "request", 1, argv);
|
||||
request->asyncResource->runInAsyncScope(
|
||||
Nan::To<v8::Object>(target->handle()->GetInternalField(1)).ToLocalChecked(),
|
||||
"request",
|
||||
1,
|
||||
argv
|
||||
);
|
||||
info.GetReturnValue().Set(info.This());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user