0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00

Tab: minor refactoring (#35511)

* remove unneeded parentheses
* move variable
This commit is contained in:
XhmikosR 2021-12-10 07:51:57 +02:00 committed by GitHub
parent 871c8bdd3f
commit 63d38b1974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,12 +5,7 @@
* --------------------------------------------------------------------------
*/
import {
defineJQueryPlugin,
getElementFromSelector,
isDisabled,
reflow
} from './util/index'
import { defineJQueryPlugin, getElementFromSelector, isDisabled, reflow } from './util/index'
import EventHandler from './dom/event-handler'
import SelectorEngine from './dom/selector-engine'
import BaseComponent from './base-component'
@ -55,15 +50,15 @@ class Tab extends BaseComponent {
// Public
show() {
if ((this._element.parentNode &&
if (this._element.parentNode &&
this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
this._element.classList.contains(CLASS_NAME_ACTIVE))) {
this._element.classList.contains(CLASS_NAME_ACTIVE)) {
return
}
let previous
const target = getElementFromSelector(this._element)
const listElement = this._element.closest(SELECTOR_NAV_LIST_GROUP)
let previous
if (listElement) {
const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE
@ -75,9 +70,7 @@ class Tab extends BaseComponent {
EventHandler.trigger(previous, EVENT_HIDE, { relatedTarget: this._element }) :
null
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
relatedTarget: previous
})
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, { relatedTarget: previous })
if (showEvent.defaultPrevented || (hideEvent !== null && hideEvent.defaultPrevented)) {
return