Proxy semantics and Object.defineProperty

Jason Orendorff jason.orendorff at
Wed Jul 13 08:14:09 PDT 2011

On the wiki page for Proxy 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}.


More information about the es-discuss mailing list