Bug 1281931 - make framework/selection.js eslint-clean; r?gregtatum
MozReview-Commit-ID: AhPQwws4WaQ
--- a/.eslintignore
+++ b/.eslintignore
@@ -75,16 +75,17 @@ browser/extensions/pocket/content/panels
browser/locales/**
# devtools/ exclusions
devtools/client/canvasdebugger/**
devtools/client/commandline/**
devtools/client/debugger/**
devtools/client/eyedropper/**
devtools/client/framework/**
+!devtools/client/framework/selection.js
devtools/client/jsonview/lib/**
devtools/client/memory/**
devtools/client/netmonitor/test/**
devtools/client/netmonitor/har/test/**
devtools/client/projecteditor/**
devtools/client/promisedebugger/**
devtools/client/responsivedesign/**
devtools/client/scratchpad/**
--- a/devtools/client/framework/selection.js
+++ b/devtools/client/framework/selection.js
@@ -2,17 +2,17 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { Cu } = require("chrome");
-const nodeConstants = require("devtools/shared/dom-node-constants.js")
+const nodeConstants = require("devtools/shared/dom-node-constants");
const { getRootBindingParent } = require("devtools/shared/layout/utils");
var EventEmitter = require("devtools/shared/event-emitter");
/**
* API
*
* new Selection(walker=null, node=null, track={attributes,detached});
* destroy()
@@ -41,31 +41,33 @@ var EventEmitter = require("devtools/sha
* isDocumentTypeNode()
* isDocumentFragmentNode()
* isNotationNode()
*
* Events:
* "new-node" when the inner node changed
* "before-new-node" when the inner node is set to change
* "attribute-changed" when an attribute is changed (only if tracked)
- * "detached" when the node (or one of its parents) is removed from the document (only if tracked)
- * "reparented" when the node (or one of its parents) is moved under a different node (only if tracked)
+ * "detached" when the node (or one of its parents) is removed from
+ * the document (only if tracked)
+ * "reparented" when the node (or one of its parents) is moved under
+ * a different node (only if tracked)
*/
/**
* A Selection object. Hold a reference to a node.
* Includes some helpers, fire some helpful events.
*
* @param node Inner node.
* Can be null. Can be (un)set in the future via the "node" property;
* @param trackAttribute Tell if events should be fired when the attributes of
* the node change.
*
*/
-function Selection(walker, node = null, track = {attributes:true, detached:true}) {
+function Selection(walker, node = null, track = {attributes: true, detached: true}) {
EventEmitter.decorate(this);
this._onMutations = this._onMutations.bind(this);
this.track = track;
this.setWalker(walker);
this.setNode(node);
}
@@ -174,17 +176,16 @@ Selection.prototype = {
// e.g. highlight the same node twice.
let rawValue = null;
if (value && value.isLocalToBeDeprecated()) {
rawValue = value.rawNode();
}
this.emit("before-new-node", rawValue, reason);
this.emit("before-new-node-front", value, reason);
let previousNode = this._node;
- let previousFront = this._nodeFront;
this._node = rawValue;
this._nodeFront = value;
this.emit("new-node", previousNode, this.reason);
this.emit("new-node-front", value, this.reason);
},
get documentFront() {
return this._walker.document(this._nodeFront);
@@ -252,63 +253,66 @@ Selection.prototype = {
return true;
}
node = node.parentNode();
}
return false;
},
isHTMLNode: function () {
- let xhtml_ns = "http://www.w3.org/1999/xhtml";
- return this.isNode() && this.nodeFront.namespaceURI == xhtml_ns;
+ let xhtmlNs = "http://www.w3.org/1999/xhtml";
+ return this.isNode() && this.nodeFront.namespaceURI == xhtmlNs;
},
// Node type
- isElementNode: function() {
+ isElementNode: function () {
return this.isNode() && this.nodeFront.nodeType == nodeConstants.ELEMENT_NODE;
},
isPseudoElementNode: function () {
return this.isNode() && this.nodeFront.isPseudoElement;
},
isAnonymousNode: function () {
return this.isNode() && this.nodeFront.isAnonymous;
},
- isAttributeNode: function() {
+ isAttributeNode: function () {
return this.isNode() && this.nodeFront.nodeType == nodeConstants.ATTRIBUTE_NODE;
},
- isTextNode: function() {
+ isTextNode: function () {
return this.isNode() && this.nodeFront.nodeType == nodeConstants.TEXT_NODE;
},
- isCDATANode: function() {
+ isCDATANode: function () {
return this.isNode() && this.nodeFront.nodeType == nodeConstants.CDATA_SECTION_NODE;
},
- isEntityRefNode: function() {
- return this.isNode() && this.nodeFront.nodeType == nodeConstants.ENTITY_REFERENCE_NODE;
+ isEntityRefNode: function () {
+ return this.isNode() &&
+ this.nodeFront.nodeType == nodeConstants.ENTITY_REFERENCE_NODE;
},
- isEntityNode: function() {
+ isEntityNode: function () {
return this.isNode() && this.nodeFront.nodeType == nodeConstants.ENTITY_NODE;
},
- isProcessingInstructionNode: function() {
- return this.isNode() && this.nodeFront.nodeType == nodeConstants.PROCESSING_INSTRUCTION_NODE;
+ isProcessingInstructionNode: function () {
+ return this.isNode() &&
+ this.nodeFront.nodeType == nodeConstants.PROCESSING_INSTRUCTION_NODE;
},
- isCommentNode: function() {
- return this.isNode() && this.nodeFront.nodeType == nodeConstants.PROCESSING_INSTRUCTION_NODE;
+ isCommentNode: function () {
+ return this.isNode() &&
+ this.nodeFront.nodeType == nodeConstants.PROCESSING_INSTRUCTION_NODE;
},
- isDocumentNode: function() {
+ isDocumentNode: function () {
return this.isNode() && this.nodeFront.nodeType == nodeConstants.DOCUMENT_NODE;
},
/**
* @returns true if the selection is the <body> HTML element.
*/
isBodyNode: function () {
return this.isHTMLNode() &&
@@ -320,20 +324,21 @@ Selection.prototype = {
* @returns true if the selection is the <head> HTML element.
*/
isHeadNode: function () {
return this.isHTMLNode() &&
this.isConnected() &&
this.nodeFront.nodeName === "HEAD";
},
- isDocumentTypeNode: function() {
+ isDocumentTypeNode: function () {
return this.isNode() && this.nodeFront.nodeType == nodeConstants.DOCUMENT_TYPE_NODE;
},
- isDocumentFragmentNode: function() {
- return this.isNode() && this.nodeFront.nodeType == nodeConstants.DOCUMENT_FRAGMENT_NODE;
+ isDocumentFragmentNode: function () {
+ return this.isNode() &&
+ this.nodeFront.nodeType == nodeConstants.DOCUMENT_FRAGMENT_NODE;
},
- isNotationNode: function() {
+ isNotationNode: function () {
return this.isNode() && this.nodeFront.nodeType == nodeConstants.NOTATION_NODE;
},
};