Skip to content

N-API: Add method to get own properties #13925

Description

@mhdawson
  • Version: ALL
  • Platform: ALL
  • Subsystem: ALL

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.

Activity

  1. self-assigned this
    on Jun 27, 2017
  2. cjihrig commented on Jun 27, 2017

    @cjihrig
    Contributor

    Working on this.

  3. cjihrig commented on Jun 28, 2017

    @cjihrig
    Contributor

    @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()?

  4. cjihrig commented on Jun 30, 2017

    @cjihrig
    Contributor

    @mhdawson ping ^

  5. added a commit that references this issue on Jul 6, 2017
  6. cjihrig commented on Jul 6, 2017

    @cjihrig
    Contributor

    Closing this out as the test has been added and napi_has_own_property() should be enough for users to build a get_own_property() as needed.

  7. added a commit that references this issue on Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

node-apiIssues and PRs related to Node-API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Sponsor
    SponsoredKunjungi sekarang
    Promo