Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 Jan 1, 2019
1 parent ae86192 commit e00b326
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/module_wrap.cc
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/node_url.cc
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 1 addition & 5 deletions src/node_url.h
Expand Up @@ -11,10 +11,6 @@
namespace node {
namespace url {

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


#define PARSESTATES(XX) \
XX(kSchemeStart) \
XX(kScheme) \
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e00b326

Please sign in to comment.