Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 1e5cae8

Browse files
committed
Cleaning and clarifying a few JavaScript
1 parent e69cd51 commit 1e5cae8

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/sidebar/tab.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ SideTab.prototype = {
113113
this._hostView.innerText = this.host;
114114
},
115115
_updateAudible(audible) {
116-
toggleClass(this._iconOverlayView, "sound", audible);
116+
this._iconOverlayView.classList.toggle("sound", audible);
117117
},
118118
_updatedMuted(muted) {
119119
this.muted = muted;
120-
toggleClass(this._iconOverlayView, "muted", muted);
120+
this._iconOverlayView.classList.toggle("muted", muted);
121121
},
122122
_updateLoading(isLoading) {
123-
toggleClass(this.view, "loading", isLoading);
123+
this.view.classList.toggle("loading", isLoading);
124124
if (isLoading) {
125125
SideTab._syncThrobberAnimations();
126126
this._notselectedsinceload = !this.view.classList.contains("active");
@@ -136,7 +136,7 @@ SideTab.prototype = {
136136
this._burstView.classList.add("bursting");
137137
},
138138
updateActive(active) {
139-
toggleClass(this.view, "active", active);
139+
this.view.classList.toggle("active", active);
140140
if (active) {
141141
this._notselectedsinceload = false;
142142
this.view.removeAttribute("notselectedsinceload");
@@ -166,7 +166,7 @@ SideTab.prototype = {
166166
},
167167
updateVisibility(show) {
168168
this.visible = show;
169-
toggleClass(this.view, "hidden", !show);
169+
this.view.classList.toggle("hidden", !show);
170170
},
171171
_setIcon(favIconUrl) {
172172
// https://bugzilla.mozilla.org/show_bug.cgi?id=1462948
@@ -191,10 +191,10 @@ SideTab.prototype = {
191191
},
192192
_updatePinned(pinned) {
193193
this.pinned = pinned;
194-
toggleClass(this.view, "pinned", pinned);
194+
this.view.classList.toggle("pinned", pinned);
195195
},
196196
_updateDiscarded(discarded) {
197-
toggleClass(this.view, "discarded", discarded);
197+
this.view.classList.toggle("discarded", discarded);
198198
},
199199
_updateThumbnail() {
200200
requestIdleCallback(async () => {
@@ -345,8 +345,4 @@ function debounce(fn, delay) {
345345
};
346346
}
347347

348-
function toggleClass(node, className, boolean) {
349-
boolean ? node.classList.add(className) : node.classList.remove(className);
350-
}
351-
352348
export default SideTab;

src/sidebar/tablist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ TabList.prototype = {
254254
},
255255
async _hasRecentlyClosedTabs() {
256256
const undoTabs = await this._getRecentlyClosedTabs();
257-
return !!undoTabs.length;
257+
return undoTabs.length > 0;
258258
},
259259
async _getRecentlyClosedTabs() {
260260
const sessions = await browser.sessions.getRecentlyClosed();

0 commit comments

Comments
 (0)