On the wiki page for Proxy semantics,
http://wiki.ecmascript.org/doku.php?id=harmony:proxies_semantics
Object.defineProperty is specified to call
NormalizePropertyDescriptor, which fills in all missing fields of the
property descriptor.
This normalization makes it impossible to implement wrappers that are
transparent to Object.defineProperty. I think it's a bug in the spec.
For example:
var obj = {x: 1};
var wrapper = Proxy.create({
defineProperty: function (name, desc) {
Object.defineProperty(obj, name, desc);
}
});
// At this point obj.x is a configurable, writable data property.
// Now if we do this:
Object.defineProperty(obj, "x", {value: 2});
// then obj.x is still configurable and writable afterwards.
// But if we do this:
Object.defineProperty(wrapper, "x", {value: 3});
// then obj.x becomes non-configurable and non-writable,
// because the proxy handler received the normalized
// descriptor {configurable: false, enumerable: false,
// writable: false, value: 3}.
-j
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss