Bug 1523812 - Handle changing the selection when there isn't already a selection. r=adw
authorDão Gottwald <dao@mozilla.com>
Fri, 01 Feb 2019 22:34:43 +0000
changeset 456519 d1b835c9d5ce607ec63c4fc2a39eebbddb01f487
parent 456518 d39849743a9c25ac34a1ad76874f33b5b09b1c96
child 456520 432ae563202be639d203852c53f7457ab08e7fac
push id111656
push userdvarga@mozilla.com
push dateSat, 02 Feb 2019 09:51:54 +0000
treeherdermozilla-inbound@d8cebb3b46cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1523812
milestone67.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 1523812 - Handle changing the selection when there isn't already a selection. r=adw Differential Revision: https://phabricator.services.mozilla.com/D18337
browser/components/urlbar/UrlbarView.jsm
--- a/browser/components/urlbar/UrlbarView.jsm
+++ b/browser/components/urlbar/UrlbarView.jsm
@@ -87,24 +87,26 @@ class UrlbarView {
     if (!this.isOpen) {
       throw new Error("UrlbarView: Cannot select an item if the view isn't open.");
     }
 
     // TODO: handle one-off search buttons
 
     let row;
     if (reverse) {
-      row = this._selected.previousElementSibling ||
+      row = (this._selected && this._selected.previousElementSibling) ||
             this._rows.lastElementChild;
     } else {
-      row = this._selected.nextElementSibling ||
+      row = (this._selected && this._selected.nextElementSibling) ||
             this._rows.firstElementChild;
     }
 
-    this._selected.toggleAttribute("selected", false);
+    if (this._selected) {
+      this._selected.toggleAttribute("selected", false);
+    }
     this._selected = row;
     row.toggleAttribute("selected", true);
 
     let resultIndex = row.getAttribute("resultIndex");
     let result = this._queryContext.results[resultIndex];
     if (result) {
       this.input.setValueFromResult(result);
     }