diff --git a/.eslintrc.json b/.eslintrc.json index bd6f452814..2ba9043432 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -164,8 +164,7 @@ }, "rules": { "no-console": "off", - "no-new": "off", - "unicorn/no-array-for-each": "off" + "no-new": "off" } }, { @@ -192,8 +191,7 @@ "ecmaVersion": 2019 }, "rules": { - "no-new": "off", - "unicorn/no-array-for-each": "off" + "no-new": "off" } }, { diff --git a/js/tests/visual/modal.html b/js/tests/visual/modal.html index efb5127b5a..fe294fa639 100644 --- a/js/tests/visual/modal.html +++ b/js/tests/visual/modal.html @@ -217,9 +217,13 @@ } } - document.querySelectorAll('[data-bs-toggle="popover"]').forEach(popoverEl => new bootstrap.Popover(popoverEl)) + for (const popoverEl of document.querySelectorAll('[data-bs-toggle="popover"]')) { + new bootstrap.Popover(popoverEl) + } - document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(tooltipEl => new bootstrap.Tooltip(tooltipEl)) + for (const tooltipEl of document.querySelectorAll('[data-bs-toggle="tooltip"]')) { + new bootstrap.Tooltip(tooltipEl) + } const tall = document.getElementById('tall') document.getElementById('tall-toggle').addEventListener('click', () => { diff --git a/js/tests/visual/popover.html b/js/tests/visual/popover.html index 73edf998d4..bbc2eb200f 100644 --- a/js/tests/visual/popover.html +++ b/js/tests/visual/popover.html @@ -35,7 +35,9 @@ diff --git a/js/tests/visual/toast.html b/js/tests/visual/toast.html index e64fd1d880..07869886de 100644 --- a/js/tests/visual/toast.html +++ b/js/tests/visual/toast.html @@ -55,14 +55,20 @@ /* global bootstrap: false */ window.addEventListener('load', () => { - document.querySelectorAll('.toast').forEach(toastEl => new bootstrap.Toast(toastEl)) + for (const toastEl of document.querySelectorAll('.toast')) { + new bootstrap.Toast(toastEl) + } document.getElementById('btnShowToast').addEventListener('click', () => { - document.querySelectorAll('.toast').forEach(toastEl => bootstrap.Toast.getInstance(toastEl).show()) + for (const toastEl of document.querySelectorAll('.toast')) { + bootstrap.Toast.getInstance(toastEl).show() + } }) document.getElementById('btnHideToast').addEventListener('click', () => { - document.querySelectorAll('.toast').forEach(toastEl => bootstrap.Toast.getInstance(toastEl).hide()) + for (const toastEl of document.querySelectorAll('.toast')) { + bootstrap.Toast.getInstance(toastEl).hide() + } }) }) diff --git a/js/tests/visual/tooltip.html b/js/tests/visual/tooltip.html index 09144b5729..eff8982eea 100644 --- a/js/tests/visual/tooltip.html +++ b/js/tests/visual/tooltip.html @@ -113,7 +113,9 @@ }) targetTooltip.show() - document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(tooltipEl => new bootstrap.Tooltip(tooltipEl)) + for (const tooltipEl of document.querySelectorAll('[data-bs-toggle="tooltip"]')) { + new bootstrap.Tooltip(tooltipEl) + } ``` diff --git a/site/static/docs/5.3/assets/js/color-modes.js b/site/static/docs/5.3/assets/js/color-modes.js index 8a0dabf181..dccd778c59 100644 --- a/site/static/docs/5.3/assets/js/color-modes.js +++ b/site/static/docs/5.3/assets/js/color-modes.js @@ -41,10 +41,10 @@ const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`) const svgOfActiveBtn = btnToActive.querySelector('svg use').getAttribute('href') - document.querySelectorAll('[data-bs-theme-value]').forEach(element => { + for (const element of document.querySelectorAll('[data-bs-theme-value]')) { element.classList.remove('active') element.setAttribute('aria-pressed', 'false') - }) + } btnToActive.classList.add('active') btnToActive.setAttribute('aria-pressed', 'true') @@ -67,14 +67,13 @@ window.addEventListener('DOMContentLoaded', () => { showActiveTheme(getPreferredTheme()) - document.querySelectorAll('[data-bs-theme-value]') - .forEach(toggle => { - toggle.addEventListener('click', () => { - const theme = toggle.getAttribute('data-bs-theme-value') - setStoredTheme(theme) - setTheme(theme) - showActiveTheme(theme, true) - }) + for (const toggle of document.querySelectorAll('[data-bs-theme-value]')) { + toggle.addEventListener('click', () => { + const theme = toggle.getAttribute('data-bs-theme-value') + setStoredTheme(theme) + setTheme(theme) + showActiveTheme(theme, true) }) + } }) })() diff --git a/site/static/docs/5.3/assets/js/validate-forms.js b/site/static/docs/5.3/assets/js/validate-forms.js index d6ab60d474..37c94a83d6 100644 --- a/site/static/docs/5.3/assets/js/validate-forms.js +++ b/site/static/docs/5.3/assets/js/validate-forms.js @@ -3,10 +3,10 @@ 'use strict' // Fetch all the forms we want to apply custom Bootstrap validation styles to - const forms = document.querySelectorAll('.needs-validation'); + const forms = document.querySelectorAll('.needs-validation') // Loop over them and prevent submission - [...forms].forEach(form => { + for (const form of forms) { form.addEventListener('submit', event => { if (!form.checkValidity()) { event.preventDefault() @@ -15,5 +15,5 @@ form.classList.add('was-validated') }, false) - }) + } })()