]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fixes #9461 - Make carousel ignore non-items in carousel-inner
authorfat <jacobthornton@gmail.com>
Tue, 25 Mar 2014 02:15:58 +0000 (19:15 -0700)
committerfat <jacobthornton@gmail.com>
Tue, 25 Mar 2014 02:23:39 +0000 (19:23 -0700)
js/carousel.js
js/tests/unit/carousel.js

index 19e9af1ed969c7ce8efe8f619990615a3e673c6d..6d6fa0aeeb7da4f63e0c3c0733e21511261a4631 100644 (file)
@@ -48,7 +48,7 @@
 
   Carousel.prototype.getActiveIndex = function () {
     this.$active = this.$element.find('.item.active')
-    this.$items  = this.$active.parent().children()
+    this.$items  = this.$active.parent().children('.item')
 
     return this.$items.index(this.$active)
   }
index 6f69855c7736541fa8b5613f3d9a544832a9877e..562e30255fd310d3dfdb8448e8524dcebbe55284 100644 (file)
@@ -107,4 +107,32 @@ $(function () {
     ok($('#myCarousel').data('bs.carousel').options.interval === false, 'data attribute has higher priority than default options')
     $('#myCarousel').remove()
   })
+
+  test('should skip over non-items', function () {
+    $.support.transition = false
+
+    var $template = $(
+        '<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"></script>'
+      + '<div class="item">'
+      + '<img alt="">'
+      + '</div>'
+      + '<div class="item">'
+      + '</div>'
+      + '</div>'
+      + '</div>'
+    )
+
+    $template.carousel()
+
+    equal($template.find('.item')[0], $template.find('.active')[0], 'the first carousel item should be active')
+
+    $template.carousel(1)
+
+    equal($template.find('.item')[1], $template.find('.active')[0], 'the second carousel item should be active')
+  })
 })