Bug 1663209 - currentIndex should return -1 when tree.view.selection is null. r=ntim
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Wed, 16 Sep 2020 07:04:33 +0000
changeset 548877 d4122bf210718638cb60388b62cc10313a95256a
parent 548876 0dcadb7f268faaf6589d6ee53b0e30d33ef83edf
child 548878 2e58da894e2f56556444272e7092cdcd254e04df
push id126437
push userntim.bugs@gmail.com
push dateWed, 16 Sep 2020 07:08:12 +0000
treeherderautoland@d4122bf21071 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersntim
bugs1663209
milestone82.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 1663209 - currentIndex should return -1 when tree.view.selection is null. r=ntim Likely happens mostly in automation. At least Thunderbird have places where the view is going to be replaced and the selection is cleared first. Differential Revision: https://phabricator.services.mozilla.com/D90253
toolkit/content/widgets/tree.js
--- a/toolkit/content/widgets/tree.js
+++ b/toolkit/content/widgets/tree.js
@@ -1061,17 +1061,20 @@
     set currentIndex(val) {
       if (this.view) {
         return (this.view.selection.currentIndex = val);
       }
       return val;
     }
 
     get currentIndex() {
-      return this.view ? this.view.selection.currentIndex : -1;
+      if (this.view && this.view.selection) {
+        return this.view.selection.currentIndex;
+      }
+      return -1;
     }
 
     set keepCurrentInView(val) {
       if (val) {
         this.setAttribute("keepcurrentinview", "true");
       } else {
         this.removeAttribute("keepcurrentinview");
       }