Bug 1839066 - Improve selection checks in places-tree. r=mak

This doesn't fix the bug but I saw some exceptions related to having a
non-null view with a null selection that this fixes.

Differential Revision: https://phabricator.services.mozilla.com/D181379
This commit is contained in:
Emilio Cobos Álvarez 2023-06-20 08:58:10 +00:00
Родитель 96a16d3cad
Коммит 65e3a8d175
1 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -223,8 +223,12 @@
return this.getAttribute("place");
}
get selectedCount() {
return this.view?.selection?.count || 0;
}
get hasSelection() {
return this.view && this.view.selection.count >= 1;
return this.selectedCount >= 1;
}
get selectedNodes() {
@ -308,12 +312,11 @@
}
get selectedNode() {
var view = this.view;
if (!view || view.selection.count != 1) {
if (this.selectedCount != 1) {
return null;
}
var selection = view.selection;
var selection = this.view.selection;
var min = {},
max = {};
selection.getRangeAt(0, min, max);