mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-21 04:41:36 +02:00
[V4] Throw error when a plugin is in transition (#17823)
* Throw error when a plugin is in transition * Add unit tests about plugins in transition
This commit is contained in:
@@ -46,11 +46,31 @@
|
||||
<script src="../../dist/carousel.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
// Should throw an error because carousel is in transition
|
||||
function testCarouselTransitionError() {
|
||||
var err = false
|
||||
var $carousel = $('#carousel-example-generic')
|
||||
$carousel.on('slid.bs.carousel', function () {
|
||||
$carousel.off('slid.bs.carousel')
|
||||
if (!err) {
|
||||
alert('No error thrown for : testCarouselTransitionError')
|
||||
}
|
||||
})
|
||||
try {
|
||||
$carousel.carousel('next').carousel('prev')
|
||||
}
|
||||
catch (e) {
|
||||
err = true
|
||||
console.error(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
// Test to show that the carousel doesn't slide when the current tab isn't visible
|
||||
$('#carousel-example-generic').on('slid.bs.carousel', function(event) {
|
||||
$('#carousel-example-generic').on('slid.bs.carousel', function (event) {
|
||||
console.log('slid at ', event.timeStamp)
|
||||
})
|
||||
testCarouselTransitionError()
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user