From ef19e608433a591471fc5c5e05353038077a5736 Mon Sep 17 00:00:00 2001
From: Donald Cook <donaldpcook@gmail.com>
Date: Mon, 3 Dec 2012 01:45:36 -0600
Subject: [PATCH] Fix for #5803: fade does not work when no default active

---
 js/bootstrap-tab.js            |  8 +++-----
 js/tests/unit/bootstrap-tab.js | 14 +++++++++++++-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/js/bootstrap-tab.js b/js/bootstrap-tab.js
index 059b39b351..f9238540d8 100644
--- a/js/bootstrap-tab.js
+++ b/js/bootstrap-tab.js
@@ -74,7 +74,7 @@
       var $active = container.find('> .active')
         , transition = callback
             && $.support.transition
-            && $active.hasClass('fade')
+            && element.hasClass('fade')
 
       function next() {
         $active
@@ -87,8 +87,6 @@
         if (transition) {
           element[0].offsetWidth // reflow for transition
           element.addClass('in')
-        } else {
-          element.removeClass('fade')
         }
 
         if ( element.parent('.dropdown-menu') ) {
@@ -98,7 +96,7 @@
         callback && callback()
       }
 
-      transition ?
+      transition && $active.length ?
         $active.one($.support.transition.end, next) :
         next()
 
@@ -130,4 +128,4 @@
     $(this).tab('show')
   })
 
-}(window.jQuery);
\ No newline at end of file
+}(window.jQuery);
diff --git a/js/tests/unit/bootstrap-tab.js b/js/tests/unit/bootstrap-tab.js
index 40f9a7406d..c005e5b8c9 100644
--- a/js/tests/unit/bootstrap-tab.js
+++ b/js/tests/unit/bootstrap-tab.js
@@ -42,6 +42,18 @@ $(function () {
         equals($("#qunit-fixture").find('.active').attr('id'), "home")
       })
 
+      test("should keep transition when no active by default", function() {
+        var tabsHTML =
+            '<ul class="tabs">'
+          + '<li><a href="#home">Home</a></li>'
+          + '<li><a href="#profile">Profile</a></li>'
+          + '</ul>'
+
+        $('<ul><li id="home"></li><li id="profile" class="fade"></li></ul>').appendTo("#qunit-fixture")
+
+        $(tabsHTML).find('li:last a').tab('show')
+        ok($("#qunit-fixture").find('.active').hasClass('fade'))
+      })
 
       test("should not fire closed when close is prevented", function () {
         $.support.transition = false
@@ -77,4 +89,4 @@ $(function () {
           }).tab('show')
       })
 
-})
\ No newline at end of file
+})
-- 
GitLab