Bug 1305401 - SimpleOutlineHighlighter checks for node validity before highlighting; r=jdescottes
MozReview-Commit-ID: 8HMcOxyJBj8
--- a/devtools/server/actors/highlighters/simple-outline.js
+++ b/devtools/server/actors/highlighters/simple-outline.js
@@ -1,16 +1,20 @@
/* 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 { installHelperSheet,
- addPseudoClassLock, removePseudoClassLock } = require("./utils/markup");
+const {
+ installHelperSheet,
+ isNodeValid,
+ addPseudoClassLock,
+ removePseudoClassLock
+} = require("./utils/markup");
// SimpleOutlineHighlighter's stylesheet
const HIGHLIGHTED_PSEUDO_CLASS = ":-moz-devtools-highlighted";
const SIMPLE_OUTLINE_SHEET = `.__fx-devtools-hide-shortcut__ {
visibility: hidden !important
}
${HIGHLIGHTED_PSEUDO_CLASS} {
outline: 2px dashed #F06!important;
@@ -36,17 +40,17 @@ SimpleOutlineHighlighter.prototype = {
this.chromeDoc = null;
},
/**
* Show the highlighter on a given node
* @param {DOMNode} node
*/
show: function (node) {
- if (!this.currentNode || node !== this.currentNode) {
+ if (isNodeValid(node) && (!this.currentNode || node !== this.currentNode)) {
this.hide();
this.currentNode = node;
installHelperSheet(node.ownerDocument.defaultView, SIMPLE_OUTLINE_SHEET);
addPseudoClassLock(node, HIGHLIGHTED_PSEUDO_CLASS);
}
return true;
},