Bug 795978 - Error: this._containers is undefined in MarkupView.jsm Line: 327; r=mratcliffe
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 30 Apr 2013 16:05:22 -0500
changeset 141930 70538913a42eaacf46c74bbc4fda52ec97ffe81b
parent 141929 a00c506762871e121fbf9307c6956e2606e8e50a
child 141931 f14297265cba9a207f27ecd6d46761a75b1397cf
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmratcliffe
bugs795978
milestone23.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 795978 - Error: this._containers is undefined in MarkupView.jsm Line: 327; r=mratcliffe
browser/devtools/markupview/markup-view.js
--- a/browser/devtools/markupview/markup-view.js
+++ b/browser/devtools/markupview/markup-view.js
@@ -63,16 +63,18 @@ function MarkupView(aInspector, aFrame, 
   this._onNewSelection();
 
   this._boundKeyDown = this._onKeyDown.bind(this);
   this._frame.contentWindow.addEventListener("keydown", this._boundKeyDown, false);
 
   this._boundFocus = this._onFocus.bind(this);
   this._frame.addEventListener("focus", this._boundFocus, false);
 
+  this._boundOnLoadRootNode = this._onLoadRootNode.bind(this);
+
   this._initPreview();
 }
 
 exports.MarkupView = MarkupView;
 
 MarkupView.prototype = {
   _selectedContainer: null,
 
@@ -308,20 +310,17 @@ MarkupView.prototype = {
     let walker = documentWalker(aNode);
     let parent = walker.parentNode();
     if (parent) {
       var container = new MarkupContainer(this, aNode);
     } else {
       var container = new RootContainer(this, aNode);
       this._elt.appendChild(container.elt);
       this._rootNode = aNode;
-      aNode.addEventListener("load", function MP_watch_contentLoaded(aEvent) {
-        // Fake a childList mutation here.
-        this._mutationObserver([{target: aEvent.target, type: "childList"}]);
-      }.bind(this), true);
+      aNode.addEventListener("load", this._boundOnLoadRootNode, true);
     }
 
     this._containers.set(aNode, container);
     // FIXME: set an expando to prevent the the wrapper from disappearing
     // See bug 819131 for details.
     aNode.__preserveHack = true;
     container.expanded = aExpand;
 
@@ -330,16 +329,24 @@ MarkupView.prototype = {
 
     if (parent) {
       this.importNode(parent, true);
     }
     return container;
   },
 
   /**
+   * Update the state of the tree once the root node is loaded.
+   */
+  _onLoadRootNode: function MV__onLoadRootNode(aEvent) {
+    // Fake a childList mutation here.
+    this._mutationObserver([{target: aEvent.target, type: "childList"}]);
+  },
+
+  /**
    * Mutation observer used for included nodes.
    */
   _mutationObserver: function MT__mutationObserver(aMutations)
   {
     for (let mutation of aMutations) {
       let container = this._containers.get(mutation.target);
       if (!container) {
         // Container might not exist if this came from a load event for an iframe
@@ -649,16 +656,19 @@ MarkupView.prototype = {
     delete this._boundUpdatePreview;
 
     this._frame.contentWindow.removeEventListener("keydown", this._boundKeyDown, true);
     delete this._boundKeyDown;
 
     this._inspector.selection.off("new-node", this._boundOnNewSelection);
     delete this._boundOnNewSelection;
 
+    this._rootNode.removeEventListener("load", this._boundOnLoadRootNode, true);
+    delete this._boundOnLoadRootNode;
+
     delete this._elt;
 
     delete this._containers;
     this._observer.disconnect();
     delete this._observer;
   },
 
   /**