0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-07 04:54:24 +01:00

Improvement: harmonize usage of constants (#30285)

This commit is contained in:
Sparks 2020-03-09 16:26:29 +01:00 committed by GitHub
parent 7d8c7c4ba8
commit c47547cd09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 8 deletions

View File

@ -25,6 +25,7 @@ const DATA_API_KEY = '.data-api'
const ClassName = { const ClassName = {
ACTIVE: 'active', ACTIVE: 'active',
BUTTON: 'btn', BUTTON: 'btn',
DISABLED: 'disabled',
FOCUS: 'focus' FOCUS: 'focus'
} }
@ -89,8 +90,8 @@ class Button {
if (triggerChangeEvent) { if (triggerChangeEvent) {
if (input.hasAttribute('disabled') || if (input.hasAttribute('disabled') ||
rootElement.hasAttribute('disabled') || rootElement.hasAttribute('disabled') ||
input.classList.contains('disabled') || input.classList.contains(ClassName.DISABLED) ||
rootElement.classList.contains('disabled')) { rootElement.classList.contains(ClassName.DISABLED)) {
return return
} }

View File

@ -81,8 +81,8 @@ class Collapse {
this._element = element this._element = element
this._config = this._getConfig(config) this._config = this._getConfig(config)
this._triggerArray = makeArray(SelectorEngine.find( this._triggerArray = makeArray(SelectorEngine.find(
`[data-toggle="collapse"][href="#${element.id}"],` + `${Selector.DATA_TOGGLE}[href="#${element.id}"],` +
`[data-toggle="collapse"][data-target="#${element.id}"]` `${Selector.DATA_TOGGLE}[data-target="#${element.id}"]`
)) ))
const toggleList = makeArray(SelectorEngine.find(Selector.DATA_TOGGLE)) const toggleList = makeArray(SelectorEngine.find(Selector.DATA_TOGGLE))
@ -313,7 +313,7 @@ class Collapse {
parent = SelectorEngine.findOne(parent) 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)) makeArray(SelectorEngine.find(selector, parent))
.forEach(element => { .forEach(element => {

View File

@ -57,6 +57,7 @@ const ClassName = {
DROPRIGHT: 'dropright', DROPRIGHT: 'dropright',
DROPLEFT: 'dropleft', DROPLEFT: 'dropleft',
MENURIGHT: 'dropdown-menu-right', MENURIGHT: 'dropdown-menu-right',
NAVBAR: 'navbar',
POSITION_STATIC: 'position-static' POSITION_STATIC: 'position-static'
} }
@ -307,7 +308,7 @@ class Dropdown {
} }
_detectNavbar() { _detectNavbar() {
return Boolean(SelectorEngine.closest(this._element, '.navbar')) return Boolean(SelectorEngine.closest(this._element, `.${ClassName.NAVBAR}`))
} }
_getOffset() { _getOffset() {

View File

@ -109,6 +109,7 @@ const Event = {
const ClassName = { const ClassName = {
FADE: 'fade', FADE: 'fade',
MODAL: 'modal',
SHOW: 'show' SHOW: 'show'
} }
@ -235,7 +236,7 @@ class Tooltip {
Data.removeData(this.element, this.constructor.DATA_KEY) Data.removeData(this.element, this.constructor.DATA_KEY)
EventHandler.off(this.element, this.constructor.EVENT_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) { if (this.tip) {
this.tip.parentNode.removeChild(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', 'hide.bs.modal',
this._hideModalHandler this._hideModalHandler
) )