diff options
author | Sparks <hollisprice.iii@gmail.com> | 2020-03-09 18:26:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 18:26:29 +0300 |
commit | c47547cd091fcb921386913ed7c0d72efd762938 (patch) | |
tree | e8ae3bb9d00d041b7381b2be0b656bdb8064da2e /js/src | |
parent | 7d8c7c4ba844f3e70b7cda20a5b813b54e43959d (diff) |
Improvement: harmonize usage of constants (#30285)
Diffstat (limited to 'js/src')
-rw-r--r-- | js/src/button.js | 5 | ||||
-rw-r--r-- | js/src/collapse.js | 6 | ||||
-rw-r--r-- | js/src/dropdown.js | 3 | ||||
-rw-r--r-- | js/src/tooltip.js | 5 |
4 files changed, 11 insertions, 8 deletions
diff --git a/js/src/button.js b/js/src/button.js index 6edd5cb64f..314d2a22a0 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -25,6 +25,7 @@ const DATA_API_KEY = '.data-api' const ClassName = { ACTIVE: 'active', BUTTON: 'btn', + DISABLED: 'disabled', FOCUS: 'focus' } @@ -89,8 +90,8 @@ class Button { if (triggerChangeEvent) { if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || - input.classList.contains('disabled') || - rootElement.classList.contains('disabled')) { + input.classList.contains(ClassName.DISABLED) || + rootElement.classList.contains(ClassName.DISABLED)) { return } diff --git a/js/src/collapse.js b/js/src/collapse.js index f533885ec4..27eef4ef72 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -81,8 +81,8 @@ class Collapse { this._element = element this._config = this._getConfig(config) this._triggerArray = makeArray(SelectorEngine.find( - `[data-toggle="collapse"][href="#${element.id}"],` + - `[data-toggle="collapse"][data-target="#${element.id}"]` + `${Selector.DATA_TOGGLE}[href="#${element.id}"],` + + `${Selector.DATA_TOGGLE}[data-target="#${element.id}"]` )) const toggleList = makeArray(SelectorEngine.find(Selector.DATA_TOGGLE)) @@ -313,7 +313,7 @@ class Collapse { parent = SelectorEngine.findOne(parent) } - const selector = `[data-toggle="collapse"][data-parent="${parent}"]` + const selector = `${Selector.DATA_TOGGLE}[data-parent="${parent}"]` makeArray(SelectorEngine.find(selector, parent)) .forEach(element => { diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 4504d61e09..82a24405aa 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -57,6 +57,7 @@ const ClassName = { DROPRIGHT: 'dropright', DROPLEFT: 'dropleft', MENURIGHT: 'dropdown-menu-right', + NAVBAR: 'navbar', POSITION_STATIC: 'position-static' } @@ -307,7 +308,7 @@ class Dropdown { } _detectNavbar() { - return Boolean(SelectorEngine.closest(this._element, '.navbar')) + return Boolean(SelectorEngine.closest(this._element, `.${ClassName.NAVBAR}`)) } _getOffset() { diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 1bc000d2cc..9b2ae6f61e 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -109,6 +109,7 @@ const Event = { const ClassName = { FADE: 'fade', + MODAL: 'modal', SHOW: 'show' } @@ -235,7 +236,7 @@ class Tooltip { Data.removeData(this.element, this.constructor.DATA_KEY) EventHandler.off(this.element, this.constructor.EVENT_KEY) - EventHandler.off(SelectorEngine.closest(this.element, '.modal'), 'hide.bs.modal', this._hideModalHandler) + EventHandler.off(SelectorEngine.closest(this.element, `.${ClassName.MODAL}`), 'hide.bs.modal', this._hideModalHandler) if (this.tip) { this.tip.parentNode.removeChild(this.tip) @@ -565,7 +566,7 @@ class Tooltip { } } - EventHandler.on(SelectorEngine.closest(this.element, '.modal'), + EventHandler.on(SelectorEngine.closest(this.element, `.${ClassName.MODAL}`), 'hide.bs.modal', this._hideModalHandler ) |