summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-05-01 23:40:02 +0200
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-05-06 05:12:27 +0200
commit5c08481aa787c49b20d0e1b86b74745990243792 (patch)
tree9cb302bbfbfee2fa782a6930ab67a3fe9972d90b /src
parentd7d6526260c7d5f150e75f7a18135be28eda0d33 (diff)
downloadandroid-node-v8-5c08481aa787c49b20d0e1b86b74745990243792.tar.gz
android-node-v8-5c08481aa787c49b20d0e1b86b74745990243792.tar.bz2
android-node-v8-5c08481aa787c49b20d0e1b86b74745990243792.zip
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')
-rw-r--r--src/js_native_api_v8.cc9
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);