Bug 1378859 - Use an ES class instead of an SDK class in the inspector front; r=gl draft
authorPatrick Brosset <pbrosset@mozilla.com>
Fri, 21 Jul 2017 14:14:48 +0200
changeset 613022 624e76537c76b77d63f54b3371647675740e48b0
parent 613010 c8e3a3ee598db6163f423adfd39c2a523dedab54
child 638584 6a385ea2c41ec54f09fefe3f7bb6d4f642a3c485
push id69695
push userbmo:pbrosset@mozilla.com
push dateFri, 21 Jul 2017 12:17:43 +0000
reviewersgl
bugs1378859
milestone56.0a1
Bug 1378859 - Use an ES class instead of an SDK class in the inspector front; r=gl MozReview-Commit-ID: 8lSSBTXsUqa
devtools/shared/fronts/inspector.js
--- a/devtools/shared/fronts/inspector.js
+++ b/devtools/shared/fronts/inspector.js
@@ -18,65 +18,64 @@ const {
   inspectorSpec,
   nodeSpec,
   nodeListSpec,
   walkerSpec
 } = require("devtools/shared/specs/inspector");
 const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const { Task } = require("devtools/shared/task");
-const { Class } = require("sdk/core/heritage");
 const events = require("sdk/event/core");
 const object = require("sdk/util/object");
 const nodeConstants = require("devtools/shared/dom-node-constants.js");
 loader.lazyRequireGetter(this, "CommandUtils",
   "devtools/client/shared/developer-toolbar", true);
 
 const HIDDEN_CLASS = "__fx-devtools-hide-shortcut__";
 
 /**
  * Convenience API for building a list of attribute modifications
  * for the `modifyAttributes` request.
  */
-const AttributeModificationList = Class({
-  initialize: function (node) {
+class AttributeModificationList {
+  constructor(node) {
     this.node = node;
     this.modifications = [];
-  },
+  }
 
-  apply: function () {
+  apply() {
     let ret = this.node.modifyAttributes(this.modifications);
     return ret;
-  },
+  }
 
-  destroy: function () {
+  destroy() {
     this.node = null;
     this.modification = null;
-  },
+  }
 
-  setAttributeNS: function (ns, name, value) {
+  setAttributeNS(ns, name, value) {
     this.modifications.push({
       attributeNamespace: ns,
       attributeName: name,
       newValue: value
     });
-  },
+  }
 
-  setAttribute: function (name, value) {
+  setAttribute(name, value) {
     this.setAttributeNS(undefined, name, value);
-  },
+  }
 
-  removeAttributeNS: function (ns, name) {
+  removeAttributeNS(ns, name) {
     this.setAttributeNS(ns, name, undefined);
-  },
+  }
 
-  removeAttribute: function (name) {
+  removeAttribute(name) {
     this.setAttributeNS(undefined, name, undefined);
   }
-});
+}
 
 /**
  * Client side of the node actor.
  *
  * Node fronts are strored in a tree that mirrors the DOM tree on the
  * server, but with a few key differences:
  *  - Not all children will be necessary loaded for each node.
  *  - The order of children isn't guaranteed to be the same as the DOM.
@@ -343,17 +342,17 @@ const NodeFront = FrontClassWithSpec(nod
   get formProperties() {
     return this._form.props;
   },
 
   /**
    * Return a new AttributeModificationList for this node.
    */
   startModifyingAttributes: function () {
-    return AttributeModificationList(this);
+    return new AttributeModificationList(this);
   },
 
   _cacheAttributes: function () {
     if (typeof this._attrMap != "undefined") {
       return;
     }
     this._attrMap = {};
     for (let attr of this.attributes) {