Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

JSResolveOp

This article needs a technical review. How you can help.

JSResolveOp is the type of the JSClass.resolve.

Syntax

typedef bool
(* JSResolveOp)(JSContext *cx, JS::HandleObject obj,
                JS::HandleId id, bool *resolvedp); // Added in JSAPI 36
typedef bool
(* JSResolveOp)(JSContext *cx, JS::HandleObject obj,
                JS::HandleId id); // Obsolete since JSAPI 36
Name Type Description
cx JSContext * Pointer to the JS context in which the property access is taking place.
obj JS::HandleObject Pointer to the object whose properties are being accessed.
id JS::HandleId The name or index of the property being resolved.
resolvedp bool * Out parameter. Receives the result of resolve operation.

Description

JSResolveOp callback is a hook which is called when a property is not found on an object.

It resolves a lazy property named by id in obj by defining it directly in obj. Lazy properties are those reflected from some peer native property space (e.g., the DOM attributes for a given node reflected as obj) on demand.

The callback must set *resolvedp to true and return true if the property is resolved, or set *resolvedp to false and return true if the object has no lazy property with the given id; or return false to indicate any other error.

Obsolete since JSAPI 36

The callback must return true if the property is resolved, or if the object has no lazy property with the given id; or false to indicate any other error.

Note: JSNewResolveOp provides a cheaper way to resolve lazy properties.

JSClass hooks

JSClass offers the following hook:

  • JSClass.resolve callback is called when a property is not found on an object. It can be used to implement lazy properties.

     

    JS looks for a property in an object, and if not found, tries to resolve the given id. After calling resolve, the engine looks again to see if resolve defined obj[id]. If so, the property lookup succeeds. If not, the process is repeated with obj's prototype.

See Also

Document Tags and Contributors

 Contributors to this page: kscarfone, arai
 Last updated by: kscarfone,