2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-08 17:22:31 +03:00

Check for data-interval on the first slide of carousel - v4 (#31820)

When starting a cycle for a carousel, it only checks for a default interval, and not an interval defined on the slide element via data props. This adds a check in before creating the interval to move to the next slide.

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
Mitchell Bryson
2020-11-12 07:34:17 +00:00
committed by GitHub
parent 9e9e1e61d5
commit 896e444895
3 changed files with 35 additions and 10 deletions
+14 -1
View File
@@ -480,7 +480,7 @@ $(function () {
})
QUnit.test('should set interval from data attribute on individual carousel-item', function (assert) {
assert.expect(2)
assert.expect(4)
var templateHTML = '<div id="myCarousel" class="carousel slide" data-interval="1814">' +
'<div class="carousel-inner">' +
'<div class="carousel-item active" data-interval="2814">' +
@@ -516,13 +516,26 @@ $(function () {
'</div>'
var $carousel = $(templateHTML)
$carousel.appendTo('body')
$carousel.bootstrapCarousel()
assert.strictEqual($carousel.data('bs.carousel')._config.interval, 1814)
$carousel.remove()
$carousel.appendTo('body')
$carousel.bootstrapCarousel(0)
$carousel.data('bs.carousel').cycle()
assert.strictEqual($carousel.data('bs.carousel')._config.interval, 2814)
$carousel.remove()
$carousel.appendTo('body')
$carousel.bootstrapCarousel(1)
$carousel.data('bs.carousel').cycle()
assert.strictEqual($carousel.data('bs.carousel')._config.interval, 3814)
$carousel.remove()
$carousel.appendTo('body')
$carousel.bootstrapCarousel(2)
$carousel.data('bs.carousel').cycle()
assert.strictEqual($carousel.data('bs.carousel')._config.interval, 1814, 'reverts to default interval if no data-interval is set')
$carousel.remove()
})