forked from LeenkxTeam/LNXRNT
Cleanup bindings and viewport
This commit is contained in:
@ -2361,7 +2361,17 @@ static void XMLHttpRequestGetResponseHeader(const FunctionCallbackInfo<Value>& a
|
||||
}
|
||||
}
|
||||
|
||||
void createXMLHttpRequestClass(Isolate* isolate, Local<ObjectTemplate>& global) {
|
||||
void bind_httprequest_class(Isolate* isolate, const Global<Context>& context) {
|
||||
HttpRequestWrapper::initialize();
|
||||
|
||||
Locker locker{isolate};
|
||||
Isolate::Scope isolate_scope(isolate);
|
||||
HandleScope handle_scope(isolate);
|
||||
|
||||
Local<Context> current_context = Local<Context>::New(isolate, context);
|
||||
Context::Scope context_scope(current_context);
|
||||
Local<Object> global = current_context->Global();
|
||||
|
||||
Local<FunctionTemplate> xhrTpl = FunctionTemplate::New(isolate, XMLHttpRequestConstructor);
|
||||
xhrTpl->SetClassName(String::NewFromUtf8(isolate, "XMLHttpRequest").ToLocalChecked());
|
||||
xhrTpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
@ -2374,14 +2384,14 @@ void createXMLHttpRequestClass(Isolate* isolate, Local<ObjectTemplate>& global)
|
||||
proto->Set(isolate, "getAllResponseHeaders", FunctionTemplate::New(isolate, XMLHttpRequestGetAllResponseHeaders));
|
||||
proto->Set(isolate, "getResponseHeader", FunctionTemplate::New(isolate, XMLHttpRequestGetResponseHeader));
|
||||
|
||||
Local<Function> xhrFunc = xhrTpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
xhrFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "UNSENT").ToLocalChecked(), Integer::New(isolate, 0));
|
||||
xhrFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "OPENED").ToLocalChecked(), Integer::New(isolate, 1));
|
||||
xhrFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "HEADERS_RECEIVED").ToLocalChecked(), Integer::New(isolate, 2));
|
||||
xhrFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "LOADING").ToLocalChecked(), Integer::New(isolate, 3));
|
||||
xhrFunc->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "DONE").ToLocalChecked(), Integer::New(isolate, 4));
|
||||
Local<Function> xhrFunc = xhrTpl->GetFunction(current_context).ToLocalChecked();
|
||||
xhrFunc->Set(current_context, String::NewFromUtf8(isolate, "UNSENT").ToLocalChecked(), Integer::New(isolate, 0));
|
||||
xhrFunc->Set(current_context, String::NewFromUtf8(isolate, "OPENED").ToLocalChecked(), Integer::New(isolate, 1));
|
||||
xhrFunc->Set(current_context, String::NewFromUtf8(isolate, "HEADERS_RECEIVED").ToLocalChecked(), Integer::New(isolate, 2));
|
||||
xhrFunc->Set(current_context, String::NewFromUtf8(isolate, "LOADING").ToLocalChecked(), Integer::New(isolate, 3));
|
||||
xhrFunc->Set(current_context, String::NewFromUtf8(isolate, "DONE").ToLocalChecked(), Integer::New(isolate, 4));
|
||||
|
||||
global->Set(isolate, "XMLHttpRequest", xhrTpl);
|
||||
global->Set(current_context, String::NewFromUtf8(isolate, "XMLHttpRequest").ToLocalChecked(), xhrFunc);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user