From 988d41b887bc5c96b17085b4a8ab34219de93e0a Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 22 Jun 2022 11:35:18 +0300 Subject: [PATCH] ref(tab): remove show from panels dependent-less they have `.fade` class or not (simplify checks) --- js/src/tab.js | 16 ++++------------ js/tests/unit/tab.spec.js | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/js/src/tab.js b/js/src/tab.js index 74bfc4148423..9fad63e920c3 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -109,13 +109,9 @@ class Tab extends BaseComponent { this._activate(getElementFromSelector(element)) // Search and activate/show the proper section - const isAnimated = element.classList.contains(CLASS_NAME_FADE) const complete = () => { - if (isAnimated) { // todo: maybe is redundant - element.classList.add(CLASS_NAME_SHOW) - } - if (element.getAttribute('role') !== 'tab') { + element.classList.add(CLASS_NAME_SHOW) return } @@ -128,7 +124,7 @@ class Tab extends BaseComponent { }) } - this._queueCallback(complete, element, isAnimated) + this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE)) } _deactivate(element, relatedElem) { @@ -141,13 +137,9 @@ class Tab extends BaseComponent { this._deactivate(getElementFromSelector(element)) // Search and deactivate the shown section too - const isAnimated = element.classList.contains(CLASS_NAME_FADE) const complete = () => { - if (isAnimated) { // todo maybe is redundant - element.classList.remove(CLASS_NAME_SHOW) - } - if (element.getAttribute('role') !== 'tab') { + element.classList.remove(CLASS_NAME_SHOW) return } @@ -157,7 +149,7 @@ class Tab extends BaseComponent { EventHandler.trigger(element, EVENT_HIDDEN, { relatedTarget: relatedElem }) } - this._queueCallback(complete, element, isAnimated) + this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE)) } _keydown(event) { diff --git a/js/tests/unit/tab.spec.js b/js/tests/unit/tab.spec.js index 110c79838390..f1c1d695c315 100644 --- a/js/tests/unit/tab.spec.js +++ b/js/tests/unit/tab.spec.js @@ -904,7 +904,7 @@ describe('Tab', () => { }) }) - it('should not add `show` class to tab panes if there is no `.fade` class', () => { + it('should add `show` class to tab panes if there is no `.fade` class', () => { return new Promise(resolve => { fixtureEl.innerHTML = [ '