-
Notifications
You must be signed in to change notification settings - Fork 154
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
Object.getOwnPropertyDescriptor handles missing arguments incorrectly #5
Comments
Please, try the patch below
|
the patch resolves original problem partially, but i'm sorry, i think it is wrong.
https://www.ecma-international.org/ecma-262/6.0/#sec-undefined-value
>> var x = {}
undefined
>> x[void 0] = 'test'
test
>> JSON.stringify(Object.getOwnPropertyDescriptor(x, void 0))
{"value":"test","configurable":"true","enumerable":"true","writable":"true"}
>> JSON.stringify(Object.getOwnPropertyDescriptor(x))
undefined same code on nodejs: > var x = {};
undefined
> x[void 0] = 'test'
'test'
> Object.getOwnPropertyDescriptor(x)
{ value: 'test',
writable: true,
enumerable: true,
configurable: true }
> Object.getOwnPropertyDescriptor(x, void 0)
{ value: 'test',
writable: true,
enumerable: true,
configurable: true } |
the second try (the patch also fixes #6 issue and partially #7 issue):
|
Thank you for the patch! It works for me (#6 is fixed too). >> Object.create()
TypeError: too few arguments
at Object.create (native)
at main (native)
>> Object.create(undefined)
TypeError: too few arguments
at Object.create (native)
at main (native)
>> Object.create(1.11)
TypeError: too few arguments
at Object.create (native)
at main (native)
>> Object.create('')
TypeError: too few arguments
at Object.create (native)
at main (native) nodejs: > Object.create()
TypeError: Object prototype may only be an Object or null: undefined
at Function.create (<anonymous>)
> Object.create(undefined)
TypeError: Object prototype may only be an Object or null: undefined
at Function.create (<anonymous>)
> Object.create('')
TypeError: Object prototype may only be an Object or null:
at Function.create (<anonymous>)
> Object.create(1.11)
TypeError: Object prototype may only be an Object or null: 1.11
at Function.create (<anonymous>) |
@xeioex PS: I think it is better not to dump an invalid value in such cases :). > Object.create(Array(100).fill('a').join())
TypeError: Object prototype may only be an Object or null: a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a
at Function.create (<anonymous>) |
The text was updated successfully, but these errors were encountered: