diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-02-10 21:46:56 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-10 21:46:56 +0530 |
commit | 39f131cd762e62e6750b61a5edd6ed0e83995a77 (patch) | |
tree | 80331418dddbfd58c222bc55597d763075b07c6e /cli/napi/js_native_api.rs | |
parent | 46817a0e3dc98197cd3e7af0b33efa3533f44ea0 (diff) |
fix(cli/napi): correct name handling in napi property descriptor (#17716)
Fixes https://github.com/denoland/deno/issues/17712
Diffstat (limited to 'cli/napi/js_native_api.rs')
-rw-r--r-- | cli/napi/js_native_api.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cli/napi/js_native_api.rs b/cli/napi/js_native_api.rs index d531c72c8..e79307714 100644 --- a/cli/napi/js_native_api.rs +++ b/cli/napi/js_native_api.rs @@ -1437,10 +1437,12 @@ fn napi_define_properties( for property in properties { let name = if !property.utf8name.is_null() { let name_str = CStr::from_ptr(property.utf8name).to_str().unwrap(); - v8::String::new(scope, name_str).ok_or(Error::GenericFailure)? + v8::String::new(scope, name_str) + .ok_or(Error::GenericFailure)? + .into() } else { let property_value = napi_value_unchecked(property.name); - v8::Local::<v8::String>::try_from(property_value) + v8::Local::<v8::Name>::try_from(property_value) .map_err(|_| Error::NameExpected)? }; @@ -1461,7 +1463,7 @@ fn napi_define_properties( desc.set_enumerable(property.attributes & napi_enumerable != 0); desc.set_configurable(property.attributes & napi_configurable != 0); - let define_maybe = object.define_property(scope, name.into(), &desc); + let define_maybe = object.define_property(scope, name, &desc); return_status_if_false!( env_ptr, !define_maybe.unwrap_or(false), |