Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize usage of constants #30285

Merged
merged 3 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions js/src/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const DATA_API_KEY = '.data-api'
const ClassName = {
ACTIVE: 'active',
BUTTON: 'btn',
DISABLED: 'disabled',
FOCUS: 'focus'
}

Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions js/src/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 => {
Expand Down
3 changes: 2 additions & 1 deletion js/src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const ClassName = {
DROPRIGHT: 'dropright',
DROPLEFT: 'dropleft',
MENURIGHT: 'dropdown-menu-right',
NAVBAR: 'navbar',
POSITION_STATIC: 'position-static'
}

Expand Down Expand Up @@ -307,7 +308,7 @@ class Dropdown {
}

_detectNavbar() {
return Boolean(SelectorEngine.closest(this._element, '.navbar'))
return Boolean(SelectorEngine.closest(this._element, `.${ClassName.NAVBAR}`))
}

_getOffset() {
Expand Down
5 changes: 3 additions & 2 deletions js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const Event = {

const ClassName = {
FADE: 'fade',
MODAL: 'modal',
SHOW: 'show'
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
Expand Down