diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-02-01 06:41:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-01 15:41:04 +0100 |
commit | 524bccdf6aa20ee4ba76dc7291d77b4c98fa7e28 (patch) | |
tree | a312f7fadf6a086f37bcc5326b42efbe114617be /cli/napi | |
parent | 1b46b2f0e47b93635b8f225f43bb82fd79dd31dc (diff) |
fix(napi): return node globalThis from napi_get_global (#17613)
Fixes https://github.com/denoland/deno/issues/17587
Diffstat (limited to 'cli/napi')
-rw-r--r-- | cli/napi/js_native_api.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cli/napi/js_native_api.rs b/cli/napi/js_native_api.rs index 62ac40159..aefe8dd0d 100644 --- a/cli/napi/js_native_api.rs +++ b/cli/napi/js_native_api.rs @@ -1718,12 +1718,12 @@ fn napi_get_element( #[napi_sym::napi_sym] fn napi_get_global(env: *mut Env, result: *mut napi_value) -> Result { check_env!(env); - let env = unsafe { &mut *env }; + check_arg!(env, result); - let context = &mut env.scope().get_current_context(); - let global = context.global(&mut env.scope()); - let value: v8::Local<v8::Value> = global.into(); + let value: v8::Local<v8::Value> = + transmute::<NonNull<v8::Value>, v8::Local<v8::Value>>((*env).global); *result = value.into(); + napi_clear_last_error(env); Ok(()) } |