1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

Use for...of in visual tests too

This commit is contained in:
GeoSot 2021-09-06 10:46:03 +03:00 committed by XhmikosR
parent 3afe4b8c7d
commit 598b4c59a6
4 changed files with 34 additions and 35 deletions

View file

@ -220,15 +220,14 @@
}
}
Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
.forEach(function (popover) {
new Popover(popover)
})
var tooltipList = Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
tooltipList.forEach(function (tooltip) {
new Tooltip(tooltip)
})
var popoverElements = document.querySelectorAll('[data-bs-toggle="popover"]')
for (const popoverEl of popoverElements) {
new Popover(popoverEl)
}
var tooltipElements = document.querySelectorAll('[data-bs-toggle="tooltip"]')
for (const tooltipEl of tooltipElements) {
new Tooltip(tooltipEl)
}
var tallToggle = document.getElementById('tall-toggle')
var tall = document.getElementById('tall')

View file

@ -40,10 +40,10 @@
<script src="../../dist/tooltip.js"></script>
<script src="../../dist/popover.js"></script>
<script>
Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
.forEach(function (popover) {
new Popover(popover)
})
var popoverElements = document.querySelectorAll('[data-bs-toggle="popover"]')
for (const popoverEl of popoverElements) {
new Popover(popoverEl)
}
</script>
</body>
</html>

View file

@ -57,26 +57,26 @@
<script src="../../dist/toast.js"></script>
<script>
window.addEventListener('load', function () {
Array.from(document.querySelectorAll('.toast'))
.forEach(function (toastNode) {
new Toast(toastNode)
})
var toastElements = document.querySelectorAll('.toast')
for (const toastEl of toastElements) {
new Toast(toastEl)
}
document.getElementById('btnShowToast').addEventListener('click', function () {
Array.from(document.querySelectorAll('.toast'))
.forEach(function (toastNode) {
var toast = Toast.getInstance(toastNode)
toast.show()
})
})
document.getElementById('btnShowToast').addEventListener('click', function () {
var toastElements = document.querySelectorAll('.toast')
for (const toastEl of toastElements) {
var toast = Toast.getInstance(toastEl)
toast.show()
}
})
document.getElementById('btnHideToast').addEventListener('click', function () {
Array.from(document.querySelectorAll('.toast'))
.forEach(function (toastNode) {
var toast = Toast.getInstance(toastNode)
toast.hide()
})
})
document.getElementById('btnHideToast').addEventListener('click', function () {
var toastElements = document.querySelectorAll('.toast')
for (const toastEl of toastElements) {
var toast = Toast.getInstance(toastEl)
toast.hide()
}
})
})
</script>
</body>

View file

@ -92,10 +92,10 @@
})
}
Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
.forEach(function (tooltip) {
new Tooltip(tooltip)
})
var tooltipElements = document.querySelectorAll('[data-bs-toggle="tooltip"]')
for (const tooltipEl of tooltipElements) {
new Tooltip(tooltipEl)
}
var tooltipElement = document.getElementById('tooltipElement')
var tooltipElementInstance = new Tooltip(tooltipElement, {