You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need a new function to allow add-ons to get own properties consistently across versions:
```C++
napi_status napi_get_own_property(napi_env e,
napi_value o,
napi_propertyname p,
napi_value* result);
which never walks up the prototype chain.
We also need to validate/ensure that napi_get_property() always walks up the prototype chain.
The N-API team will get to this based on priorities, but this is a good place for others to contribute as well. If you start working on this, assign the issue to yourself and add a comment that you are working on it.
@mhdawson I added a test for napi_get_property() walking the prototype chain in #13961. I'm questioning if we really need a napi_get_own_property() though. I understand the use case, but wouldn't it be better to have napi_has_own_property(), which would correspond to Object.prototype.hasOwnProperty()?
Activity
cjihrig commentedon Jun 27, 2017
Working on this.
cjihrig commentedon Jun 28, 2017
@mhdawson I added a test for
napi_get_property()walking the prototype chain in #13961. I'm questioning if we really need anapi_get_own_property()though. I understand the use case, but wouldn't it be better to havenapi_has_own_property(), which would correspond toObject.prototype.hasOwnProperty()?cjihrig commentedon Jun 30, 2017
@mhdawson ping ^
test: verify napi_get_property() walks prototype
test: verify napi_get_property() walks prototype
n-api: add napi_has_own_property()
cjihrig commentedon Jul 6, 2017
Closing this out as the test has been added and
napi_has_own_property()should be enough for users to build aget_own_property()as needed.test: verify napi_get_property() walks prototype
n-api: add napi_has_own_property()
test: verify napi_get_property() walks prototype
n-api: add napi_has_own_property()
n-api: add napi_has_own_property()
test: verify napi_get_property() walks prototype
n-api: add napi_has_own_property()