proposal identical to current ES5-6 one except [[HasOwnProperty]]
is used instead
When the abstract operation ToPropertyDescriptor is called with object Obj, the following steps are taken:
- ReturnIfAbrupt(Obj).
- If Type(Obj) is not Object throw a TypeError exception.
- Let desc be a new Property Descriptor that initially has no fields.
- If HasOwnProperty(Obj, "enumerable") is true, then
- Let enum be Get(Obj, "enumerable").
- ReturnIfAbrupt(enum).
- Set the [[Enumerable]] field of desc to ToBoolean(enum).
- If HasOwnProperty(Obj, "configurable") is true, then
- Let conf be Get(Obj, "configurable").
- ReturnIfAbrupt(conf).
- Set the [[Configurable]] field of desc to ToBoolean(conf).
- If HasOwnProperty(Obj, "value") is true, then
- Let value be Get(Obj, "value").
- ReturnIfAbrupt(value).
- Set the [[Value]] field of desc to value.
- If HasOwnProperty(Obj, "writable") is true, then
- Let writable be Get(Obj, "writable").
- ReturnIfAbrupt(writable).
- Set the [[Writable]] field of desc to ToBoolean(writable).
- If HasOwnProperty(Obj, "get") is true, then
- Let getter be Get(Obj, "get").
- ReturnIfAbrupt(getter).
- If IsCallable(getter) is false and getter is not undefined, then throw a TypeError exception.
- Set the [[Get]] field of desc to getter.
- If HasOwnProperty(Obj, "set") is true, then
- Let setter be Get(Obj, "set").
- ReturnIfAbrupt(setter).
- If IsCallable(setter) is false and setter is not undefined, then throw a TypeError exception.
- Set the [[Set]] field of desc to setter.
- If either desc.[[Get]] or desc.[[Set]] are present, then
- If either desc.[[Value]] or desc.[[Writable]] are present, then throw a TypeError exception.
- Set the [[Origin]] field of desc to Obj.
- Return desc.
The End