Bug 1686950 - [devtools] Remove string concatenation to toggle RDM from toolbox r=nchevobbe

Depends on D103326

Spotted while writing the patch, makes the code unnecessarily hard to navigate.

Differential Revision: https://phabricator.services.mozilla.com/D103687
This commit is contained in:
Julian Descottes 2021-02-02 19:08:45 +00:00
Родитель 36fd4f01e4
Коммит 98d054740b
1 изменённых файлов: 9 добавлений и 2 удалений

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

@ -86,12 +86,19 @@ class ResponsiveUIManager {
* the UI has closed, there is no resolution value. * the UI has closed, there is no resolution value.
*/ */
toggle(window, tab, options = {}) { toggle(window, tab, options = {}) {
const action = this.isActiveForTab(tab) ? "close" : "open"; const completed = this._toggleForTab(window, tab, options);
const completed = this[action + "IfNeeded"](window, tab, options);
completed.catch(console.error); completed.catch(console.error);
return completed; return completed;
} }
_toggleForTab(window, tab, options) {
if (this.isActiveForTab(tab)) {
return this.closeIfNeeded(window, tab, options);
}
return this.openIfNeeded(window, tab, options);
}
/** /**
* Opens the responsive UI, if not already open. * Opens the responsive UI, if not already open.
* *