Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make carousel ignore non-items in carousel-inner #9461

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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)
}
Expand Down
25 changes: 25 additions & 0 deletions js/tests/unit/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,29 @@ $(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", 4, function () {
var template = $('<div id="myCarousel" class="carousel">' +
'<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.attr("data-interval", 1814);

template.appendTo("body");
$("#myCarousel").carousel(1);

equal($("#myCarousel .item.active").length, 1);
equal($("#myCarousel .item:nth-of-type(2)").length, 1);
ok($("#myCarousel .item.active")[0] == $("#myCarousel .item:nth-of-type(2)")[0], "The 2nd item should be active after advancing");
ok(!$("#thingy").is(":visible"), "2nd child of .carousel-inner should not be visible");
})
})