From 82715ae96dad4e97d208acf7f1654b25449e2bef Mon Sep 17 00:00:00 2001 From: Kevin Attfield Date: Sun, 30 Sep 2012 21:41:37 -0700 Subject: [PATCH 1/2] Fix for #5362 Fix for issue [5362](https://github.com/twitter/bootstrap/issues/5362): tab events fired on wrong dropdown anchor. --- js/bootstrap-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 48a8dd2a23f11981d42785db4091c029b5b7e781 Mon Sep 17 00:00:00 2001 From: Kevin Attfield Date: Mon, 8 Oct 2012 22:29:44 -0700 Subject: [PATCH 2/2] Added test to fix for #5362 --- js/tests/unit/bootstrap-tab.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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