diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-06-10 17:51:01 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2021-07-22 17:54:48 +0300 |
commit | d3c6f25fd0cc811a681f3a6b88708c04b2c9b797 (patch) | |
tree | b0e569df918f4c3b1ea2ab8fd0556ac90d5bad02 | |
parent | da2db218edfc0746c169b567e6a13c9f8e945dda (diff) |
Add `isShown` method and reuse it
-rw-r--r-- | js/src/dropdown.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 681369b484..d9bd903c18 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -11,12 +11,12 @@ import { defineJQueryPlugin, getElement, getElementFromSelector, + getNextActiveElement, isDisabled, isElement, - isVisible, isRTL, + isVisible, noop, - getNextActiveElement, typeCheckConfig } from './util/index' import EventHandler from './dom/event-handler' @@ -128,7 +128,7 @@ class Dropdown extends BaseComponent { return } - const isActive = this._element.classList.contains(CLASS_NAME_SHOW) + const isActive = this._isShown() if (isActive) { this.hide() @@ -139,7 +139,7 @@ class Dropdown extends BaseComponent { } show() { - if (isDisabled(this._element) || this._menu.classList.contains(CLASS_NAME_SHOW)) { + if (isDisabled(this._element) || this._isShown(this._menu)) { return } @@ -201,7 +201,7 @@ class Dropdown extends BaseComponent { } hide() { - if (isDisabled(this._element) || !this._menu.classList.contains(CLASS_NAME_SHOW)) { + if (isDisabled(this._element) || !this._isShown(this._menu)) { return } @@ -279,6 +279,10 @@ class Dropdown extends BaseComponent { return config } + _isShown(element = this._element) { + return element.classList.contains(CLASS_NAME_SHOW) + } + _getMenuElement() { return SelectorEngine.next(this._element, SELECTOR_MENU)[0] } @@ -398,7 +402,7 @@ class Dropdown extends BaseComponent { continue } - if (!context._element.classList.contains(CLASS_NAME_SHOW)) { + if (!context._isShown()) { continue } |