nl_tokens: === fundamental traps === If name denotes a fixed property check : - whether targetHandler reports it as existent - whether the returned descriptor is compatible with the fixed property If the proxy is non - extensible check : - whether name is not a new property Additionally the returned descriptor is normalized and completed .
pl_tokens: function ( name ) { "use strict" ; var trap = this . getTrap ( "getOwnPropertyDescriptor" ) ; if ( trap === undefined ) { return Reflect . getOwnPropertyDescriptor ( this . target , name ) ; } name = String ( name ) ; var desc = trap . call ( this . handler , this . target , name ) ; desc = normalizeAndCompletePropertyDescriptor ( desc ) ; var targetDesc = Object . getOwnPropertyDescriptor ( this . target , name ) ; var extensible = Object . isExtensible ( this . target ) ; if ( desc === undefined ) { if ( isSealedDesc ( targetDesc ) ) { throw new TypeError ( "cannot report non-configurable property '" + name + "' as non-existent" ) ; } if ( ! extensible && targetDesc !== undefined ) { // if handler is allowed to return undefined, we cannot guarantee // that it will not return a descriptor for this property later. // Once a property has been reported as non-existent on a non-extensible // object, it should forever be reported as non-existent throw new TypeError ( "cannot report existing own property '" + name + "' as non-existent on a non-extensible object" ) ; } return undefined ; } // at this point, we know (desc !== undefined), i.e. // targetHandler reports 'name' as an existing property // Note: we could collapse the following two if-tests into a single // test. Separating out the cases to improve error reporting. if ( ! extensible ) { if ( targetDesc === undefined ) { throw new TypeError ( "cannot report a new own property '" + name + "' on a non-extensible object" ) ; } } if ( <mask> !== undefined ) { if ( ! isCompatibleDescriptor ( extensible , targetDesc , desc ) ) { throw new TypeError ( "cannot report incompatible property descriptor " + "for property '" + name + "'" ) ; } } if ( desc . configurable === false && ! isSealedDesc ( targetDesc ) ) { // if the property is configurable or non-existent on the target, // but is reported as a non-configurable property, it may later be // reported as configurable or non-existent, which violates the // invariant that if the property might change or disappear, the // configurable attribute must be true. throw new TypeError ( "cannot report a non-configurable descriptor " + "for configurable or non-existent property '" + name + "'" ) ; } return desc ; }