diff --git a/js/bootstrap-tab.js b/js/bootstrap-tab.js index 4fb3c38399..b4e142864e 100644 --- a/js/bootstrap-tab.js +++ b/js/bootstrap-tab.js @@ -49,7 +49,7 @@ if ( $this.parent('li').hasClass('active') ) return - previous = $ul.find('.active a').last()[0] + previous = $ul.find('.active:last a')[0] e = $.Event('show', { relatedTarget: previous diff --git a/js/tests/unit/bootstrap-tab.js b/js/tests/unit/bootstrap-tab.js index 9878047810..40f9a7406d 100644 --- a/js/tests/unit/bootstrap-tab.js +++ b/js/tests/unit/bootstrap-tab.js @@ -58,4 +58,23 @@ $(function () { .tab('show') }) + test("show and shown events should reference correct relatedTarget", function () { + var dropHTML = + '' + + $(dropHTML).find('ul>li:first a').tab('show').end() + .find('ul>li:last a').on('show', function(event){ + equals(event.relatedTarget.hash, "#1-1") + }).on('shown', function(event){ + equals(event.relatedTarget.hash, "#1-1") + }).tab('show') + }) + }) \ No newline at end of file