Web Inspector: REGRESSION(r238599): Uncaught Exception: TypeError: null is not an...
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2018 03:34:54 +0000 (03:34 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2018 03:34:54 +0000 (03:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192090
<rdar://problem/46318614>

Reviewed by Devin Rousso.

* UserInterface/Views/TreeOutline.js:
(WI.TreeOutline.prototype.selectionControllerSelectionDidChange):
Check that `listItemElement` is valid before accessing it to update class
names. The selection can change before the TreeElement has been attached.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239246 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

index 0a2ae0d..e344c35 100644 (file)
@@ -1,5 +1,18 @@
 2018-12-14  Matt Baker  <mattbaker@apple.com>
 
+        Web Inspector: REGRESSION(r238599): Uncaught Exception: TypeError: null is not an object (evaluating 'treeElement.listItemElement.classList')
+        https://bugs.webkit.org/show_bug.cgi?id=192090
+        <rdar://problem/46318614>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Views/TreeOutline.js:
+        (WI.TreeOutline.prototype.selectionControllerSelectionDidChange):
+        Check that `listItemElement` is valid before accessing it to update class
+        names. The selection can change before the TreeElement has been attached.
+
+2018-12-14  Matt Baker  <mattbaker@apple.com>
+
         Web Inspector: Cookies view should use model objects instead of raw payload data
         https://bugs.webkit.org/show_bug.cgi?id=189533
         <rdar://problem/44364183>
index 247b657..cc8bb2d 100644 (file)
@@ -803,7 +803,8 @@ WI.TreeOutline = class TreeOutline extends WI.Object
             let treeElement = this._treeElementAtIndex(index);
             console.assert(treeElement, "Missing TreeElement for deselected index " + index);
             if (treeElement) {
-                treeElement.listItemElement.classList.remove("selected");
+                if (treeElement.listItemElement)
+                    treeElement.listItemElement.classList.remove("selected");
                 if (!this._suppressNextSelectionDidChangeEvent)
                     treeElement.deselect();
             }
@@ -813,7 +814,8 @@ WI.TreeOutline = class TreeOutline extends WI.Object
             let treeElement = this._treeElementAtIndex(index);
             console.assert(treeElement, "Missing TreeElement for selected index " + index);
             if (treeElement) {
-                treeElement.listItemElement.classList.add("selected");
+                if (treeElement.listItemElement)
+                    treeElement.listItemElement.classList.add("selected");
                 if (!this._suppressNextSelectionDidChangeEvent)
                     treeElement.select();
             }
@@ -821,12 +823,12 @@ WI.TreeOutline = class TreeOutline extends WI.Object
 
         let selectedTreeElement = this.selectedTreeElement;
         if (selectedTreeElement !== this._previousSelectedTreeElement) {
-            if (this._previousSelectedTreeElement)
+            if (this._previousSelectedTreeElement && this._previousSelectedTreeElement.listItemElement)
                 this._previousSelectedTreeElement.listItemElement.classList.remove("last-selected");
 
             this._previousSelectedTreeElement = selectedTreeElement;
 
-            if (this._previousSelectedTreeElement)
+            if (this._previousSelectedTreeElement && this._previousSelectedTreeElement.listItemElement)
                 this._previousSelectedTreeElement.listItemElement.classList.add("last-selected");
         }