chakra-core / chakra-core/ChakraCore

Add API to store private properties in any object

Open
#3,592 2 comments 0 reactions 0 assignees View on GitHub
Feature Request
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

It's possible right now to create an "External Object" which stores a C pointer to internal native data. However, what's *not* possible as far as I can see is being able to store arbitrary properties on an object which refer to JS values but aren't accessible from JS. For example in Duktape it's possible to:

```c
duk_push_object(ctx);
/* populate new object with anything needed */
duk_put_prop_string(ctx, -2, "\xff""hiddenObject");
```

That can be done with any object, whereas in Chakra you currently have to create an external object to store private data--and it's not possible to convert an existing standard JS object to an external one, either, which means that in native constructors for external objects, you can't use the automatic `this` and must instead return a fresh object from the constructor.

I propose an API that would either:
* Add an API that converts an existing standard JS object to an External object, **OR**:
* Add an API for storing "hidden" properties that could be accessed using `Js[GS]etProperty()` but not within JavaScript code. Perhaps something like `JsCreateHiddenPropertyId()`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.