B2G/gecko/browser/devtools/debugger/debugger-view.js
/**
   * Adds a property to a specified variable.
   * If the optional id is not specified, the property html node will have a
   * default id set as aVar.id->aKey-property.
   *
   * @param object aVar
   *        The parent variable element.
   * @param array aProperty
   *        An array containing the key and grip properties, specifying
   *        the value and/or type & class of the variable (if the type
   *        is not specified, it will be inferred from the value).
   *        e.g. ["someProp0", 42]
   *             ["someProp1", true]
   *             ["someProp2", "nasu"]
   *             ["someProp3", { type: "undefined" }]
   *             ["someProp4", { type: "null" }]
   *             ["someProp5", { type: "object", class: "Object" }]
   * @param object aFlags
   *        Contains configurable, enumerable or writable flags.
   * @param string aName
   *        Optional, the property name.
   * @paarm string aId
   *        Optional, an id for the property html node.
   * @return object
   *         The newly created html node representing the added prop.
   */
Adds a property to a specified variable.
If the optional id is not specified, the property html node will have a
default id set as aVar.id->aKey-property.

@param object aVar
The parent variable element.
@param array aProperty
An array containing the key and grip properties, specifying
the value and/or type & class of the variable (if the type
is not specified, it will be inferred from the value).
Adds a property to a specified variable . If the optional id is not specified the property html node will have a default id set as aVar . id - > aKey - property . @param object aVar The parent variable element . @param array aProperty An array containing the key and grip properties specifying the value and / or type & class of the variable ( if the type is not specified it will be inferred from the value ) .
function DVP__addProperty(aVar, aProperty, aFlags, aName, aId) {
    if (!aVar) {
      return null;
    }
    aId = aId || (aVar.id + "->" + aProperty[0] + "-property");
    let element = this._createPropertyElement(aName, aId, "property",
                                              aVar.getElementsByClassName("details")[0]);
    if (!element) {
      return null;
    }
    element._identifier = aName;
    element.setGrip = this._setGrip.bind(this, element);
    element.addProperties = this._addProperties.bind(this, element);
    element.refresh(function(pKey, pGrip) {
      let title = element.getElementsByClassName("title")[0];
      let nameLabel = title.getElementsByClassName("name")[0];
      let separatorLabel = document.createElement("label");
      let valueLabel = document.createElement("label");
      this._setAttributes(element, pKey, aFlags);
      if ("undefined" !== typeof pKey) {
        nameLabel.className = "key plain";
        nameLabel.setAttribute("value", pKey.trim());
        title.appendChild(nameLabel);
      }
      if ("undefined" !== typeof pGrip) {
        separatorLabel.className = "plain";
        separatorLabel.setAttribute("value", ":");
        valueLabel.className = "value plain";
        this._applyGrip(valueLabel, pGrip);
        title.appendChild(separatorLabel);
        title.appendChild(valueLabel);
      }
      valueLabel.addEventListener("click", this._activateElementInputMode.bind({
        scope: this,
        element: element,
        valueLabel: valueLabel
      }));
      Object.defineProperty(element, "token", {
        value: aVar.token + "['" + pKey + "']",
        writable: false,
        enumerable: true,
        configurable: true
      });
      this._saveHierarchy({
        parent: aVar,
        element: element,
        valueLabel: valueLabel
      });
      Object.defineProperty(aVar, pKey, { value: element,
                                          writable: false,
                                          enumerable: true,
                                          configurable: true });
    }.bind(this), aProperty);
    return element;
  }
function DVP__addProperty ( aVar , aProperty , aFlags , aName , aId ) { if ( ! aVar ) { return null ; } aId = aId || ( aVar . id + "->" + aProperty [ 0 ] + "-property" ) ; let element = this . _createPropertyElement ( aName , aId , "property" , aVar . getElementsByClassName ( "details" ) [ 0 ] ) ; if ( ! element ) { return null ; } element . _identifier = aName ; element . setGrip = this . _setGrip . bind ( this , element ) ; element . addProperties = this . _addProperties . bind ( this , element ) ; element . refresh ( function ( pKey , pGrip ) { let title = element . getElementsByClassName ( "title" ) [ 0 ] ; let nameLabel = title . getElementsByClassName ( "name" ) [ 0 ] ; let separatorLabel = document . createElement ( "label" ) ; let valueLabel = document . createElement ( "label" ) ; this . _setAttributes ( element , pKey , aFlags ) ; if ( "undefined" !== typeof pKey ) { nameLabel . className = "key plain" ; nameLabel . setAttribute ( "value" , pKey . trim ( ) ) ; title . appendChild ( nameLabel ) ; } if ( "undefined" !== typeof pGrip ) { separatorLabel . className = "plain" ; separatorLabel . setAttribute ( "value" , ":" ) ; valueLabel . className = "value plain" ; this . _applyGrip ( valueLabel , pGrip ) ; title . appendChild ( separatorLabel ) ; title . appendChild ( valueLabel ) ; } valueLabel . addEventListener ( "click" , this . _activateElementInputMode . bind ( { scope : this , element : element , valueLabel : valueLabel } ) ) ; Object . defineProperty ( element , "token" , { value : aVar . token + "['" + pKey + "']" , writable : false , enumerable : true , configurable : true } ) ; this . _saveHierarchy ( { parent : aVar , element : element , valueLabel : valueLabel } ) ; Object . defineProperty ( aVar , pKey , { value : element , writable : false , enumerable : true , configurable : true } ) ; } . bind ( this ) , aProperty ) ; return element ; }
Adds a property to a specified variable.
Adds a property to a specified variable .
// Make sure the variable container exists. // Compute the id of the element if not specified. // Contains generic nodes and functionality. // Make sure the element was created successfully. /**
     * @see DebuggerView.Properties._setGrip
     */ /**
     * @see DebuggerView.Properties._addProperties
     */ // Setup the additional elements specific for a variable node. // Use attribute flags to specify the element type and tooltip text. // Use a key element to specify the property name. // Separator between the variable name and its value. // Use a value element to specify the property value. // Handle the click event when pressing the element value label. // Maintain the symbolic name of the property. // Remember a simple hierarchy between the parent and the element. // Save the property to the variable for easier access. // Return the element for later use if necessary.