1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-13 09:04:14 +02:00

Fix #13818 by using more robust "find next carousel item" logic

Also adds another test for #9461: carousel next/prev should ignore non-items
This commit is contained in:
Chris Rebert
2014-07-07 19:05:48 -07:00
parent fc1db2e74b
commit cbba8e53df
2 changed files with 35 additions and 3 deletions

View File

@@ -349,7 +349,7 @@ $(function () {
$carousel.remove()
})
test('should skip over non-items', function () {
test('should skip over non-items when using item indices', function () {
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
@@ -373,4 +373,29 @@ $(function () {
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
})
test('should skip over non-items when using next/prev methods', function () {
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
+ '<img alt="">'
+ '</div>'
+ '<script type="text/x-metamorph" id="thingy"/>'
+ '<div class="item">'
+ '<img alt="">'
+ '</div>'
+ '<div class="item">'
+ '</div>'
+ '</div>'
+ '</div>'
var $template = $(templateHTML)
$template.bootstrapCarousel()
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
$template.bootstrapCarousel('next')
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
})
})