mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-07 04:54:24 +01:00
Remaining JS linting TODO (#29289)
* Enable and fix all occurrences with no-mixed-operators rule * Take care of the max-depth warning in button.js Signed-off-by: mhatvan <markus_hatvan@aon.at>
This commit is contained in:
parent
6885d65578
commit
4d101491da
@ -27,7 +27,7 @@
|
|||||||
"always-multiline"
|
"always-multiline"
|
||||||
],
|
],
|
||||||
"new-cap": "off",
|
"new-cap": "off",
|
||||||
"no-mixed-operators": "off",
|
"no-mixed-operators": "error",
|
||||||
"object-curly-spacing": [
|
"object-curly-spacing": [
|
||||||
"error",
|
"error",
|
||||||
"always"
|
"always"
|
||||||
|
@ -74,17 +74,15 @@ class Button {
|
|||||||
if (rootElement) {
|
if (rootElement) {
|
||||||
const input = SelectorEngine.findOne(Selector.INPUT, this._element)
|
const input = SelectorEngine.findOne(Selector.INPUT, this._element)
|
||||||
|
|
||||||
if (input) {
|
if (input && input.type === 'radio') {
|
||||||
if (input.type === 'radio') {
|
if (input.checked &&
|
||||||
if (input.checked &&
|
this._element.classList.contains(ClassName.ACTIVE)) {
|
||||||
this._element.classList.contains(ClassName.ACTIVE)) {
|
triggerChangeEvent = false
|
||||||
triggerChangeEvent = false
|
} else {
|
||||||
} else {
|
const activeElement = SelectorEngine.findOne(Selector.ACTIVE, rootElement)
|
||||||
const activeElement = SelectorEngine.findOne(Selector.ACTIVE, rootElement)
|
|
||||||
|
|
||||||
if (activeElement) {
|
if (activeElement) {
|
||||||
activeElement.classList.remove(ClassName.ACTIVE)
|
activeElement.classList.remove(ClassName.ACTIVE)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,8 +377,8 @@ class Carousel {
|
|||||||
const isPrevDirection = direction === Direction.PREV
|
const isPrevDirection = direction === Direction.PREV
|
||||||
const activeIndex = this._getItemIndex(activeElement)
|
const activeIndex = this._getItemIndex(activeElement)
|
||||||
const lastItemIndex = this._items.length - 1
|
const lastItemIndex = this._items.length - 1
|
||||||
const isGoingToWrap = isPrevDirection && activeIndex === 0 ||
|
const isGoingToWrap = (isPrevDirection && activeIndex === 0) ||
|
||||||
isNextDirection && activeIndex === lastItemIndex
|
(isNextDirection && activeIndex === lastItemIndex)
|
||||||
|
|
||||||
if (isGoingToWrap && !this._config.wrap) {
|
if (isGoingToWrap && !this._config.wrap) {
|
||||||
return activeElement
|
return activeElement
|
||||||
@ -424,8 +424,8 @@ class Carousel {
|
|||||||
_slide(direction, element) {
|
_slide(direction, element) {
|
||||||
const activeElement = SelectorEngine.findOne(Selector.ACTIVE_ITEM, this._element)
|
const activeElement = SelectorEngine.findOne(Selector.ACTIVE_ITEM, this._element)
|
||||||
const activeElementIndex = this._getItemIndex(activeElement)
|
const activeElementIndex = this._getItemIndex(activeElement)
|
||||||
const nextElement = element || activeElement &&
|
const nextElement = element || (activeElement &&
|
||||||
this._getItemByDirection(direction, activeElement)
|
this._getItemByDirection(direction, activeElement))
|
||||||
|
|
||||||
const nextElementIndex = this._getItemIndex(nextElement)
|
const nextElementIndex = this._getItemIndex(nextElement)
|
||||||
const isCycling = Boolean(this._interval)
|
const isCycling = Boolean(this._interval)
|
||||||
|
@ -81,7 +81,7 @@ const nativeEvents = [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function getUidEvent(element, uid) {
|
function getUidEvent(element, uid) {
|
||||||
return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++
|
return (uid && `${uid}::${uidEvent++}`) || element.uidEvent || uidEvent++
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEvent(element) {
|
function getEvent(element) {
|
||||||
|
@ -390,7 +390,7 @@ class Dropdown {
|
|||||||
|
|
||||||
static clearMenus(event) {
|
static clearMenus(event) {
|
||||||
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH ||
|
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH ||
|
||||||
event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
|
(event.type === 'keyup' && event.which !== TAB_KEYCODE))) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,9 +415,9 @@ class Dropdown {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event && (event.type === 'click' &&
|
if (event && ((event.type === 'click' &&
|
||||||
/input|textarea/i.test(event.target.tagName) ||
|
/input|textarea/i.test(event.target.tagName)) ||
|
||||||
event.type === 'keyup' && event.which === TAB_KEYCODE) &&
|
(event.type === 'keyup' && event.which === TAB_KEYCODE)) &&
|
||||||
parent.contains(event.target)) {
|
parent.contains(event.target)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -459,9 +459,9 @@ class Dropdown {
|
|||||||
// - If key is not up or down => not a dropdown command
|
// - If key is not up or down => not a dropdown command
|
||||||
// - If trigger inside the menu => not a dropdown command
|
// - If trigger inside the menu => not a dropdown command
|
||||||
if (/input|textarea/i.test(event.target.tagName) ?
|
if (/input|textarea/i.test(event.target.tagName) ?
|
||||||
event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE &&
|
event.which === SPACE_KEYCODE || (event.which !== ESCAPE_KEYCODE &&
|
||||||
(event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE ||
|
((event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE) ||
|
||||||
SelectorEngine.closest(event.target, Selector.MENU)) :
|
SelectorEngine.closest(event.target, Selector.MENU))) :
|
||||||
!REGEXP_KEYDOWN.test(event.which)) {
|
!REGEXP_KEYDOWN.test(event.which)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -476,7 +476,7 @@ class Dropdown {
|
|||||||
const parent = Dropdown.getParentFromElement(this)
|
const parent = Dropdown.getParentFromElement(this)
|
||||||
const isActive = parent.classList.contains(ClassName.SHOW)
|
const isActive = parent.classList.contains(ClassName.SHOW)
|
||||||
|
|
||||||
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
|
if (!isActive || (isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE))) {
|
||||||
if (event.which === ESCAPE_KEYCODE) {
|
if (event.which === ESCAPE_KEYCODE) {
|
||||||
SelectorEngine.findOne(Selector.DATA_TOGGLE, parent).focus()
|
SelectorEngine.findOne(Selector.DATA_TOGGLE, parent).focus()
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,9 @@ class Tab {
|
|||||||
// Public
|
// Public
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
if (this._element.parentNode &&
|
if ((this._element.parentNode &&
|
||||||
this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
|
this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
|
||||||
this._element.classList.contains(ClassName.ACTIVE) ||
|
this._element.classList.contains(ClassName.ACTIVE)) ||
|
||||||
this._element.classList.contains(ClassName.DISABLED)) {
|
this._element.classList.contains(ClassName.DISABLED)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ class Tab {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (showEvent.defaultPrevented ||
|
if (showEvent.defaultPrevented ||
|
||||||
hideEvent !== null && hideEvent.defaultPrevented) {
|
(hideEvent !== null && hideEvent.defaultPrevented)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user