fix: accessor descriptors from Proxy getOwnPropertyDescriptor trap - #1658
Open
NathanWalker wants to merge 1 commit into
Open
fix: accessor descriptors from Proxy getOwnPropertyDescriptor trap#1658NathanWalker wants to merge 1 commit into
NathanWalker wants to merge 1 commit into
Conversation
js_obj_to_desc() returns defineProperty-style flags (JS_PROP_HAS_GET / JS_PROP_HAS_SET, never JS_PROP_GETSET), but js_proxy_get_own_property() published the parsed trap result unconverted. Descriptor consumers test JS_PROP_GETSET, so any accessor descriptor returned by a getOwnPropertyDescriptor trap degraded to a data descriptor { value: undefined, writable: false }.
Convert the flags to own-property form before publishing, per the CompletePropertyDescriptor(resultDesc) step of Proxy [[GetOwnProperty]]:
```
const t = {};
Object.defineProperty(t, 'x', { configurable: true, get() { return 42; } });
const p = new Proxy(t, { getOwnPropertyDescriptor: Reflect.getOwnPropertyDescriptor });
Object.getOwnPropertyDescriptor(p, 'x');
// before: { value: undefined, writable: false, ... }
// after: { get: [Function], set: undefined, ... }
```
Embedders exposing host objects through descriptor-trap proxies hit this in practice (eg, NativeScript's iOS runtime did).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
js_obj_to_desc() returns defineProperty-style flags (JS_PROP_HAS_GET / JS_PROP_HAS_SET, never JS_PROP_GETSET), but js_proxy_get_own_property() published the parsed trap result unconverted. Descriptor consumers test JS_PROP_GETSET, so any accessor descriptor returned by a getOwnPropertyDescriptor trap degraded to a data descriptor { value: undefined, writable: false }.
Convert the flags to own-property form before publishing, per the CompletePropertyDescriptor(resultDesc) step of Proxy [[GetOwnProperty]]:
Embedders exposing host objects through descriptor-trap proxies hit this in practice (eg, NativeScript's iOS runtime did).