From 4a2d337bf5f329eac1ca16208414ec1ebfe0546e Mon Sep 17 00:00:00 2001 From: fat Date: Mon, 24 Mar 2014 19:15:58 -0700 Subject: [PATCH] fixes #9461 - Make carousel ignore non-items in carousel-inner --- js/carousel.js | 2 +- js/tests/unit/carousel.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/js/carousel.js b/js/carousel.js index 19e9af1ed9..6d6fa0aeeb 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -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) } diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 6f69855c77..562e30255f 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -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 = $( + '' + ) + + $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') + }) })