Bug 1393760 - Avoid to fire multiple new-node-front events for undefined nodeFront. r=ochameau
authorLuca Greco <lgreco@mozilla.com>
Tue, 16 Oct 2018 17:54:47 +0000
changeset 500139 1604addc1fc97587040e1b17e6e454ce54328703
parent 500138 bfb92e2d55e43b25ee6256c7a037ead4022c3f8d
child 500140 ddaf0bd9ee3ae6da8cbb809a36b8c089e07d8655
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1393760
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1393760 - Avoid to fire multiple new-node-front events for undefined nodeFront. r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D8856
devtools/client/framework/selection.js
--- a/devtools/client/framework/selection.js
+++ b/devtools/client/framework/selection.js
@@ -135,18 +135,26 @@ Selection.prototype = {
     this.reason = reason;
 
     // If an inlineTextChild text node is being set, then set it's parent instead.
     const parentNode = nodeFront && nodeFront.parentNode();
     if (nodeFront && parentNode && parentNode.inlineTextChild === nodeFront) {
       nodeFront = parentNode;
     }
 
+    if (this._nodeFront == null && nodeFront == null) {
+      // Avoid to notify multiple "unselected" events with a null/undefined nodeFront
+      // (e.g. once when the webpage start to navigate away from the current webpage,
+      // and then again while the new page is being loaded).
+      return;
+    }
+
     this._isSlotted = isSlotted;
     this._nodeFront = nodeFront;
+
     this.emit("new-node-front", nodeFront, this.reason);
   },
 
   get documentFront() {
     return this._walker.document(this._nodeFront);
   },
 
   get nodeFront() {