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.

JSDeletePropertyOp

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

This article covers features introduced in SpiderMonkey 24

The type of the JSClass.delProperty.

Syntax

typedef bool
(* JSDeletePropertyOp)(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
                       bool *succeeded);
Name Type Description
cx JSContext *

The context in which the property access is taking place. Provides request. In JS_THREADSAFE builds, the JavaScript engine calls this callback only from within an active request on cx. The callback does not need to call JS_BeginRequest()).

obj JS::HandleObject The object whose properties are being deleted.
id JS::HandleId The name or index of the property being deleted. This is either a string (Unicode property identifier) or an integer (element index).
succeeded bool * Out parameter. Receives the result of deletion.

Description

JSDeletePropertyOp callback is a hook that applications may install to be called at some point during property access. A JSDeletePropertyOp may be installed on a JSClass to hook property deletes.

If a JSDeletePropertyOp does nothing and returns true, then property delete is unaffected. It proceeds as normal.

This callback may veto the ongoing property operation by optionally reporting an error or raising an exception and then returning false. The operation then fails, and the error is propagated to the caller. Otherwise the callback must return true, and the property operation proceeds.

JSClass hooks

JSClass offers the following hook:

  • JSClass.delProperty is called during most property deletions, even when obj has no property named id.

    If an error occurred, return false as per normal JSAPI error practice.

    If no error occurred, but the deletion attempt wasn't allowed (perhaps because the property was non-configurable), set *succeeded to false and return true. This will cause delete obj[id] to evaluate to false in non-strict mode code, and to throw a TypeError in strict mode code.

    If no error occurred and the deletion wasn't disallowed (this is *not* the same as saying that a deletion actually occurred -- deleting a non-existent property, or an inherited property, is allowed -- it's just pointless), set *succeeded to true and return true.

    This hook is not called when the target property is JSPROP_PERMANENT and is an own property of the target object. An attempt to delete such a property fails early, returning false, before the delProperty hook is reached.

    JS_ClearScope does not call this hook either.

See Also

Document Tags and Contributors

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