Freeze closed tabs methods

This commit is contained in:
Thomas Brouard 2016-11-01 11:05:21 +01:00
parent 0f69a9f441
commit 8f3b243a6f

View file

@ -143,6 +143,7 @@ class Tab extends EventEmitter {
} }
setTitle (title) { setTitle (title) {
if (this.isClosed) return;
let span = this.tabElements.title; let span = this.tabElements.title;
span.innerHTML = title; span.innerHTML = title;
this.title = title; this.title = title;
@ -150,10 +151,12 @@ class Tab extends EventEmitter {
} }
getTitle () { getTitle () {
if (this.isClosed) return;
return this.title; return this.title;
} }
setIcon (iconURL) { setIcon (iconURL) {
if (this.isClosed) return;
this.iconURL = iconURL; this.iconURL = iconURL;
let span = this.tabElements.icon; let span = this.tabElements.icon;
if (iconURL) { if (iconURL) {
@ -163,6 +166,7 @@ class Tab extends EventEmitter {
} }
getIcon () { getIcon () {
if (this.isClosed) return;
return this.iconURL; return this.iconURL;
} }
@ -178,6 +182,7 @@ class Tab extends EventEmitter {
} }
tabClickHandler (e) { tabClickHandler (e) {
if (this.isClosed) return;
if (e.which === 1) { if (e.which === 1) {
this.activate(); this.activate();
} else if (e.which === 2) { } else if (e.which === 2) {
@ -186,6 +191,7 @@ class Tab extends EventEmitter {
} }
activate () { activate () {
if (this.isClosed) return;
let activeTab = this.tabGroup.getActiveTab(); let activeTab = this.tabGroup.getActiveTab();
if (activeTab) { if (activeTab) {
activeTab.tab.classList.remove("active"); activeTab.tab.classList.remove("active");
@ -198,6 +204,7 @@ class Tab extends EventEmitter {
} }
flash (flag) { flash (flag) {
if (this.isClosed) return;
if (flag !== false) { if (flag !== false) {
this.tab.classList.add("flash"); this.tab.classList.add("flash");
this.emit("flash-start", this); this.emit("flash-start", this);
@ -212,7 +219,8 @@ class Tab extends EventEmitter {
} }
close (force) { close (force) {
if (!this.closable && !force) return; if (this.isClosed || (!this.closable && !force)) return;
this.isClosed = true;
let tabGroup = this.tabGroup; let tabGroup = this.tabGroup;
tabGroup.tabContainer.removeChild(this.tab); tabGroup.tabContainer.removeChild(this.tab);
tabGroup.viewContainer.removeChild(this.webview); tabGroup.viewContainer.removeChild(this.webview);