From: GeoSot Date: Mon, 27 Jun 2022 09:43:11 +0000 (+0300) Subject: ref(tab): remove show from panels dependent-less they have `.fade` class or not ... X-Git-Tag: v5.2.0~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f14c58f49471e7880cb8a13c74d88febc1c0c21d;p=thirdparty%2Fbootstrap.git ref(tab): remove show from panels dependent-less they have `.fade` class or not (simplify checks) (#36622) --- diff --git a/js/src/tab.js b/js/src/tab.js index 74bfc41484..9fad63e920 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 110c798383..f1c1d695c3 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 = [ '