Add tab.hasClass() method

This commit is contained in:
Thomas Brouard 2020-03-12 21:56:23 +01:00
parent 16d13ed95d
commit a15110a2bb
2 changed files with 8 additions and 0 deletions

View file

@ -196,6 +196,10 @@ Toggle the "visible" class on the tab. `tab.hide()` is an alias to `tab.show(fal
Toggle the "flash" class on the tab. `tab.unflash()` is an alias to `tab.flash(false)`.
#### `tab.hasClass(classname)`
Return `true` if the tab element has the specified classname. Useful for checking if a tab is "active", "visible" of "flash".
#### `tab.close(force)`
Close the tab (and activate another tab if relevant). When `force` is set to `true` the tab will be closed even if it is not `closable`.

View file

@ -341,6 +341,10 @@ class Tab extends EventEmitter {
return this.flash(false);
}
hasClass (classname) {
return this.tab.classList.contains(classname);
}
close (force) {
const abortController = new AbortController();
const abort = () => abortController.abort();