diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-05-01 23:40:02 +0200 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-05-06 05:12:27 +0200 |
commit | 5c08481aa787c49b20d0e1b86b74745990243792 (patch) | |
tree | 9cb302bbfbfee2fa782a6930ab67a3fe9972d90b /src/js_native_api_v8.cc | |
parent | d7d6526260c7d5f150e75f7a18135be28eda0d33 (diff) | |
download | node-new-5c08481aa787c49b20d0e1b86b74745990243792.tar.gz |
n-api: make napi_get_property_names return strings
The documentation says that this method returns an array of strings.
Currently, it does not do so for indices. Resolve that by telling
V8 explicitly to convert to string.
PR-URL: https://github.com/nodejs/node/pull/27524
Fixes: https://github.com/nodejs/node/issues/27496
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src/js_native_api_v8.cc')
-rw-r--r-- | src/js_native_api_v8.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index e05163c32f..befef0af65 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -870,7 +870,14 @@ napi_status napi_get_property_names(napi_env env, v8::Local<v8::Object> obj; CHECK_TO_OBJECT(env, context, obj, object); - auto maybe_propertynames = obj->GetPropertyNames(context); + v8::MaybeLocal<v8::Array> maybe_propertynames = obj->GetPropertyNames( + context, + v8::KeyCollectionMode::kIncludePrototypes, + static_cast<v8::PropertyFilter>( + v8::PropertyFilter::ONLY_ENUMERABLE | + v8::PropertyFilter::SKIP_SYMBOLS), + v8::IndexFilter::kIncludeIndices, + v8::KeyConversionMode::kConvertToString); CHECK_MAYBE_EMPTY(env, maybe_propertynames, napi_generic_failure); |