Bug 1305401 - SimpleOutlineHighlighter checks for node validity before highlighting; r=jdescottes draft
authorPatrick Brosset <pbrosset@mozilla.com>
Mon, 26 Sep 2016 17:25:50 +0200
changeset 417657 066e6eaf756a9f3cc6d04a81dcd4873773942cd3
parent 417649 c55bcb7c777ea09431b4d16903ed079ae5632648
child 532132 1823ea59ec13372a1c5d5af1e27273e95060a5b9
push id30449
push userbmo:pbrosset@mozilla.com
push dateMon, 26 Sep 2016 15:29:39 +0000
reviewersjdescottes
bugs1305401
milestone52.0a1
Bug 1305401 - SimpleOutlineHighlighter checks for node validity before highlighting; r=jdescottes MozReview-Commit-ID: 8HMcOxyJBj8
devtools/server/actors/highlighters/simple-outline.js
--- 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;
   },