summaryrefslogtreecommitdiff
path: root/src/node_url.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_url.cc')
-rw-r--r--src/node_url.cc40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/node_url.cc b/src/node_url.cc
index 02f9e58097..078e155fc4 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -19,11 +19,13 @@ using v8::CFunction;
using v8::Context;
using v8::FastOneByteString;
using v8::FunctionCallbackInfo;
+using v8::FunctionTemplate;
using v8::HandleScope;
using v8::Isolate;
using v8::Local;
using v8::NewStringType;
using v8::Object;
+using v8::ObjectTemplate;
using v8::String;
using v8::Value;
@@ -322,22 +324,25 @@ void BindingData::UpdateComponents(const ada::url_components& components,
"kURLComponentsLength should be up-to-date");
}
-void BindingData::Initialize(Local<Object> target,
- Local<Value> unused,
- Local<Context> context,
- void* priv) {
- Realm* realm = Realm::GetCurrent(context);
- BindingData* const binding_data =
- realm->AddBindingData<BindingData>(context, target);
- if (binding_data == nullptr) return;
-
- SetMethodNoSideEffect(context, target, "domainToASCII", DomainToASCII);
- SetMethodNoSideEffect(context, target, "domainToUnicode", DomainToUnicode);
- SetMethodNoSideEffect(context, target, "format", Format);
- SetMethod(context, target, "parse", Parse);
- SetMethod(context, target, "update", Update);
+void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
+ Local<FunctionTemplate> ctor) {
+ Isolate* isolate = isolate_data->isolate();
+ Local<ObjectTemplate> target = ctor->InstanceTemplate();
+ SetMethodNoSideEffect(isolate, target, "domainToASCII", DomainToASCII);
+ SetMethodNoSideEffect(isolate, target, "domainToUnicode", DomainToUnicode);
+ SetMethodNoSideEffect(isolate, target, "format", Format);
+ SetMethod(isolate, target, "parse", Parse);
+ SetMethod(isolate, target, "update", Update);
SetFastMethodNoSideEffect(
- context, target, "canParse", CanParse, &fast_can_parse_);
+ isolate, target, "canParse", CanParse, &fast_can_parse_);
+}
+
+void BindingData::CreatePerContextProperties(Local<Object> target,
+ Local<Value> unused,
+ Local<Context> context,
+ void* priv) {
+ Realm* realm = Realm::GetCurrent(context);
+ realm->AddBindingData<BindingData>(context, target);
}
void BindingData::RegisterExternalReferences(
@@ -365,6 +370,9 @@ std::string FromFilePath(const std::string_view file_path) {
} // namespace node
-NODE_BINDING_CONTEXT_AWARE_INTERNAL(url, node::url::BindingData::Initialize)
+NODE_BINDING_CONTEXT_AWARE_INTERNAL(
+ url, node::url::BindingData::CreatePerContextProperties)
+NODE_BINDING_PER_ISOLATE_INIT(
+ url, node::url::BindingData::CreatePerIsolateProperties)
NODE_BINDING_EXTERNAL_REFERENCE(
url, node::url::BindingData::RegisterExternalReferences)