defineProperty reject behavior

This strawman was accepted and integrated into direct proxies

In the current Proxy API, the defineProperty trap cannot faithfully emulate the reject behavior of [[DefineOwnProperty]]. As WebIDL may make use of this reject behavior, proxies need to emulate it in order to faithfully wrap the DOM.

Proposal: have the defineProperty trap return a boolean that indicates success. If false is returned, the built-in [[DefineOwnProperty]] method of a Proxy determines whether to fail silently or to throw an exception, depending on strictness. This change is compatible with the existing API, in which defineProperty‘s return value is ignored. It is also consistent with the signature of the set and delete traps.

Updated Semantics

[[DefineOwnProperty]] (P, Desc, Throw)

When the [[DefineOwnProperty]] internal method of a trapping proxy O is called with property name P, property descriptor Desc and Boolean flag Throw, the following steps are taken:

  1. Let descObj be FromGenericPropertyDescriptor(Desc)
  2. Let success be the result of calling TrapDefineOwnProperty(O, P, descObj, Throw)
  3. If ToBoolean(success) is false
    • a. If Throw then throw a TypeError exception, else return false.
  4. Return true.

See proxies_semantics for the definition of TrapDefineOwnProperty.


  • es-discuss post by David Flanagan, pointing out the necessity of emulating defineProperty reject behavior.
strawman/defineproperty_reject_behavior.txt · Last modified: 2011/11/24 07:24 by tomvc
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki