summaryrefslogtreecommitdiff
path: root/src/js_native_api_v8.cc
diff options
context:
space:
mode:
authorMichael Dawson <mdawson@devrus.com>2020-11-10 10:20:28 -0500
committerMichael Dawson <mdawson@devrus.com>2020-11-17 17:12:28 -0500
commitcbfa2d11d4e42ea7f6a847a6930fd1022773252e (patch)
tree91a1ab3fdf9e36a3b99703914c3135e1bee4c486 /src/js_native_api_v8.cc
parent8d6b74d3474080bd29dd698f55e88aba17c6a69e (diff)
downloadnode-new-cbfa2d11d4e42ea7f6a847a6930fd1022773252e.tar.gz
n-api: improve consistency of how we get context
Refs: https://github.com/nodejs/node-addon-api/issues/764 Improve the consistency of how we get a context when needed. We generally used env->context() in N-API but there were are few exceptions that this PR addresses. Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: https://github.com/nodejs/node/pull/36068 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Diffstat (limited to 'src/js_native_api_v8.cc')
-rw-r--r--src/js_native_api_v8.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 0a3494ce70..64e4298e12 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -169,7 +169,7 @@ inline static napi_status ConcludeDeferred(napi_env env,
NAPI_PREAMBLE(env);
CHECK_ARG(env, result);
- v8::Local<v8::Context> context = env->isolate->GetCurrentContext();
+ v8::Local<v8::Context> context = env->context();
v8impl::Persistent<v8::Value>* deferred_ref =
NodePersistentFromJsDeferred(deferred);
v8::Local<v8::Value> v8_deferred =
@@ -385,8 +385,7 @@ inline static napi_status Unwrap(napi_env env,
CHECK_ARG(env, result);
}
- v8::Isolate* isolate = env->isolate;
- v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Context> context = env->context();
v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(js_object);
RETURN_STATUS_IF_FALSE(env, value->IsObject(), napi_invalid_arg);