From 5c08481aa787c49b20d0e1b86b74745990243792 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 1 May 2019 23:40:02 +0200 Subject: 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 Reviewed-By: Minwoo Jung Reviewed-By: Ruben Bridgewater --- src/js_native_api_v8.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/js_native_api_v8.cc') 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 obj; CHECK_TO_OBJECT(env, context, obj, object); - auto maybe_propertynames = obj->GetPropertyNames(context); + v8::MaybeLocal maybe_propertynames = obj->GetPropertyNames( + context, + v8::KeyCollectionMode::kIncludePrototypes, + static_cast( + v8::PropertyFilter::ONLY_ENUMERABLE | + v8::PropertyFilter::SKIP_SYMBOLS), + v8::IndexFilter::kIncludeIndices, + v8::KeyConversionMode::kConvertToString); CHECK_MAYBE_EMPTY(env, maybe_propertynames, napi_generic_failure); -- cgit v1.2.1