Bug 1378859 - Use an ES class instead of an SDK class in the inspector front; r=gl
MozReview-Commit-ID: 8lSSBTXsUqa
--- 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) {