mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-21 18:54:30 +01:00
Add isShown
method and reuse it
This commit is contained in:
parent
da2db218ed
commit
d3c6f25fd0
@ -11,12 +11,12 @@ import {
|
|||||||
defineJQueryPlugin,
|
defineJQueryPlugin,
|
||||||
getElement,
|
getElement,
|
||||||
getElementFromSelector,
|
getElementFromSelector,
|
||||||
|
getNextActiveElement,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
isElement,
|
isElement,
|
||||||
isVisible,
|
|
||||||
isRTL,
|
isRTL,
|
||||||
|
isVisible,
|
||||||
noop,
|
noop,
|
||||||
getNextActiveElement,
|
|
||||||
typeCheckConfig
|
typeCheckConfig
|
||||||
} from './util/index'
|
} from './util/index'
|
||||||
import EventHandler from './dom/event-handler'
|
import EventHandler from './dom/event-handler'
|
||||||
@ -128,7 +128,7 @@ class Dropdown extends BaseComponent {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const isActive = this._element.classList.contains(CLASS_NAME_SHOW)
|
const isActive = this._isShown()
|
||||||
|
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
this.hide()
|
this.hide()
|
||||||
@ -139,7 +139,7 @@ class Dropdown extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
if (isDisabled(this._element) || this._menu.classList.contains(CLASS_NAME_SHOW)) {
|
if (isDisabled(this._element) || this._isShown(this._menu)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ class Dropdown extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
if (isDisabled(this._element) || !this._menu.classList.contains(CLASS_NAME_SHOW)) {
|
if (isDisabled(this._element) || !this._isShown(this._menu)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +279,10 @@ class Dropdown extends BaseComponent {
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isShown(element = this._element) {
|
||||||
|
return element.classList.contains(CLASS_NAME_SHOW)
|
||||||
|
}
|
||||||
|
|
||||||
_getMenuElement() {
|
_getMenuElement() {
|
||||||
return SelectorEngine.next(this._element, SELECTOR_MENU)[0]
|
return SelectorEngine.next(this._element, SELECTOR_MENU)[0]
|
||||||
}
|
}
|
||||||
@ -398,7 +402,7 @@ class Dropdown extends BaseComponent {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context._element.classList.contains(CLASS_NAME_SHOW)) {
|
if (!context._isShown()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user