Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.eslintrc.json1
-rw-r--r--js/src/carousel.js12
-rw-r--r--js/src/collapse.js7
-rw-r--r--js/src/dom/event-handler.js4
-rw-r--r--js/src/dropdown.js4
-rw-r--r--js/src/util/sanitizer.js7
6 files changed, 15 insertions, 20 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index 72b267691c..302c765985 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -53,7 +53,6 @@
"unicorn/no-array-callback-reference": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-array-method-this-argument": "off",
- "unicorn/no-for-loop": "off",
"unicorn/no-null": "off",
"unicorn/no-unused-properties": "error",
"unicorn/numeric-separators-style": "off",
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 96812d3b6a..322ad46a09 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -366,10 +366,10 @@ class Carousel extends BaseComponent {
const indicators = SelectorEngine.find(SELECTOR_INDICATOR, this._indicatorsElement)
- for (let i = 0; i < indicators.length; i++) {
- if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
- indicators[i].classList.add(CLASS_NAME_ACTIVE)
- indicators[i].setAttribute('aria-current', 'true')
+ for (const indicator of indicators) {
+ if (Number.parseInt(indicator.getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
+ indicator.classList.add(CLASS_NAME_ACTIVE)
+ indicator.setAttribute('aria-current', 'true')
break
}
}
@@ -574,8 +574,8 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.da
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)
- for (let i = 0, len = carousels.length; i < len; i++) {
- Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]))
+ for (const carousel of carousels) {
+ Carousel.carouselInterface(carousel, Carousel.getInstance(carousel))
}
})
diff --git a/js/src/collapse.js b/js/src/collapse.js
index 4ed0dadd6e..dd42bc7e78 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -75,8 +75,7 @@ class Collapse extends BaseComponent {
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
- for (let i = 0, len = toggleList.length; i < len; i++) {
- const elem = toggleList[i]
+ for (const elem of toggleList) {
const selector = getSelectorFromElement(elem)
const filterElement = SelectorEngine.find(selector)
.filter(foundElem => foundElem === this._element)
@@ -203,9 +202,7 @@ class Collapse extends BaseComponent {
this._element.classList.add(CLASS_NAME_COLLAPSING)
this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW)
- const triggerArrayLength = this._triggerArray.length
- for (let i = 0; i < triggerArrayLength; i++) {
- const trigger = this._triggerArray[i]
+ for (const trigger of this._triggerArray) {
const elem = getElementFromSelector(trigger)
if (elem && !this._isShown(elem)) {
diff --git a/js/src/dom/event-handler.js b/js/src/dom/event-handler.js
index 47f610493a..2aa687bb13 100644
--- a/js/src/dom/event-handler.js
+++ b/js/src/dom/event-handler.js
@@ -129,8 +129,8 @@ function bootstrapDelegationHandler(element, selector, fn) {
function findHandler(events, handler, delegationSelector = null) {
const uidEventList = Object.keys(events)
- for (let i = 0, len = uidEventList.length; i < len; i++) {
- const event = events[uidEventList[i]]
+ for (const uidEvent of uidEventList) {
+ const event = events[uidEvent]
if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
return event
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index f241be699c..335abaf05e 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -377,8 +377,8 @@ class Dropdown extends BaseComponent {
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
- for (let i = 0, len = toggles.length; i < len; i++) {
- const context = Dropdown.getInstance(toggles[i])
+ for (const toggle of toggles) {
+ const context = Dropdown.getInstance(toggle)
if (!context || context._config.autoClose === false) {
continue
}
diff --git a/js/src/util/sanitizer.js b/js/src/util/sanitizer.js
index 2a0597be79..c02a4eb906 100644
--- a/js/src/util/sanitizer.js
+++ b/js/src/util/sanitizer.js
@@ -46,8 +46,8 @@ const allowedAttribute = (attribute, allowedAttributeList) => {
const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp)
// Check if a regular expression validates the attribute.
- for (let i = 0, len = regExp.length; i < len; i++) {
- if (regExp[i].test(attributeName)) {
+ for (const element of regExp) {
+ if (element.test(attributeName)) {
return true
}
}
@@ -102,8 +102,7 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')
const elements = [].concat(...createdDocument.body.querySelectorAll('*'))
- for (let i = 0, len = elements.length; i < len; i++) {
- const element = elements[i]
+ for (const element of elements) {
const elementName = element.nodeName.toLowerCase()
if (!Object.keys(allowList).includes(elementName)) {