Skip to content
Permalink
Browse files

src: pass along MaybeLocal<> state from `URL::ToObject()`

PR-URL: #25141
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
  • Loading branch information...
addaleax authored and targos committed Dec 19, 2018
1 parent ae86192 commit e00b326f33f9d610e5856978d07d1e34977e38a1
Showing with 6 additions and 8 deletions.
  1. +3 −1 src/module_wrap.cc
  2. +2 −2 src/node_url.cc
  3. +1 −5 src/node_url.h
@@ -708,7 +708,9 @@ void ModuleWrap::Resolve(const FunctionCallbackInfo<Value>& args) {
return node::THROW_ERR_MISSING_MODULE(env, msg.c_str());
}

args.GetReturnValue().Set(result.FromJust().ToObject(env));
MaybeLocal<Value> obj = result.FromJust().ToObject(env);
if (!obj.IsEmpty())
args.GetReturnValue().Set(obj.ToLocalChecked());
}

static MaybeLocal<Promise> ImportModuleDynamically(
@@ -2381,7 +2381,7 @@ URL URL::FromFilePath(const std::string& file_path) {
// This function works by calling out to a JS function that creates and
// returns the JS URL object. Be mindful of the JS<->Native boundary
// crossing that is required.
const Local<Value> URL::ToObject(Environment* env) const {
MaybeLocal<Value> URL::ToObject(Environment* env) const {
Isolate* isolate = env->isolate();
Local<Context> context = env->context();
Context::Scope context_scope(context);
@@ -2417,7 +2417,7 @@ const Local<Value> URL::ToObject(Environment* env) const {
->Call(env->context(), undef, arraysize(argv), argv);
}

return ret.ToLocalChecked();
return ret;
}

static void SetURLConstructor(const FunctionCallbackInfo<Value>& args) {
@@ -11,10 +11,6 @@
namespace node {
namespace url {

using v8::Local;
using v8::Value;


#define PARSESTATES(XX) \
XX(kSchemeStart) \
XX(kScheme) \
@@ -171,7 +167,7 @@ class URL {
// Get the file URL from native file system path.
static URL FromFilePath(const std::string& file_path);

const Local<Value> ToObject(Environment* env) const;
v8::MaybeLocal<v8::Value> ToObject(Environment* env) const;

URL(const URL&) = default;
URL& operator=(const URL&) = default;

0 comments on commit e00b326

Please sign in to comment.
You can’t perform that action at this time.