-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per May 2016 TC39 consensus, Object.getOwnPropertyDescriptors
is now stage 4!
#582
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we run this step also when descriptor is undefined? (Could happen if obj is a proxy, for instance.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's perfectly fine. If a Proxy chooses to expose that it is a Proxy by providing a key in
[[OwnPropertyKeys]]
that does not have a corresponding descriptor in[[GetOwnProperty]]
, I think that intentional information leak should be propagated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if you
Object.getOwnpropertyDescriptor(proxy, key)
and/orReflect.ownKeys(proxyObject)
?On Wed, May 25, 2016 at 3:24 PM, Claude Pache [email protected]
wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reflect.ownKeys
should return the same as[[OwnPropertyKeys]]
, andObject.getOwnPropertyDescriptor
I believe will call[[GetOwnProperty]]
, so I think you'd getundefined
for a key from a Proxy that had this inconsistent behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
Object.defineProperties
accepts undefined in place of a property descriptor, it is probably fine forObject.getOwnPropertyDescriptors
to produce undefined in place of a property descriptor, so that the following code will work:I’ve checked thatObject.defineProperties
does indeed accept undefined in place of a descriptor since ES6 (see step 5b), but the browsers still do not. (And test262 apparently forgot to be updated.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my similarly-weak preference is that it should just pass through what the MOP gives it and not be responsible for normalizing or censoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My weak preference is the same as @domenic's - also, this same "issue" already exists with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this as normalizing or censoring. To me, if GetOwnProperty returns undefined, the property doesn't exist. The fact that previously OwnKeys said the property was there is of no consequence - maybe it doesn't exist now because the proxy is confused, or maybe there were side effects that removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is the core of our disagreement: if GetOwnProperty returns undefined, that to me means that its property descriptor is undefined. That can be true if the property doesn't exist, but it can also be true if the proxy wants to return undefined and the property does exist.
Basically, "what does it mean to exist"? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no such thing as a property with an undefined property descriptor. Proxies may change their answers about whether a property exists, but if a property exists, it has a property descriptor.