[Harmony Proxies] Proposal: Property fixing

Sean Eagan seaneagan1 at gmail.com
Wed May 4 09:04:51 PDT 2011


Honor attempts to make individual proxy properties non-configurable.


For consistency since attempts to make *all* of a proxy's properties
non-configurable are honored via the "fix" trap.


var x = Proxy.create({
  defineProperty: function() {},
  getPropertyDescriptor: function() {
    return {
      value: "whatever I want",
      writable: true,
      configurable: true,
      enumerable: false
Object.defineProperty(x, "foo", {value: "bar", configurable: false,
writable: false, enumerable: true};

/* ... */

// logs "whatever I want", not "bar"
// non-writable, but doesn't throw
object.foo = "baz";
// non-configurable, but doesn't throw
Object.defineProperty(x, "foo", {configurable: true});


Assume a "defineProperty" trap invocation due to
|Object.defineProperty(proxy, name, pd)| where |!pd.configurable|.  If
return value is...

  true - Henceforth bypass |proxy|'s handler for any traps with a
property name parameter when the property name would be |name|
  false - throw TypeError similarly to "fix" trap

Update the "fix" trap semantics such that when its return value is not
undefined but rather a property descriptor map, behavior is similar to
|Object.defineProperties| in that improperly redefining any properties
will cause a TypeError to be thrown.


Can check |Object.getOwnPropertyDescriptor(proxy, name).configurable|
to determine if a given proxy property is fixed since it will always
be false in this case.

Sean Eagan

More information about the es-discuss mailing list