diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 78dddbeade808e44e243f18080ea2721fb2aec40..cee2d782cdfb36569da827320021aa6eb2ae4822 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -147,6 +147,8 @@ .css(tp) .addClass(placement) .addClass('in') + + $tip.data('re-entered', 'true') } } @@ -162,11 +164,12 @@ var that = this , $tip = this.tip() - $tip.removeClass('in') + $tip.removeClass('in').data('re-entered', 'false') function removeWithAnimation() { var timeout = setTimeout(function () { - $tip.off($.support.transition.end).remove() + $tip.off($.support.transition.end) + if ($tip.data('re-entered') === 'false') $tip.remove() }, 500) $tip.one($.support.transition.end, function () { diff --git a/js/tests/index.html b/js/tests/index.html index 976ca16872b62aefd2af4b444429e4aabef4eab7..887ac4deb662a8aeab21dede3703799e5c5fafc5 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -53,4 +53,4 @@ <div id="qunit-fixture"></div> </div> </body> -</html> \ No newline at end of file +</html> diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 9844d6460f7b0fdd0065d4776a3556e078d0ba5c..ba66df1144869c8096c34c80c1090fa3d6764e68 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -128,6 +128,28 @@ $(function () { }, 200) }) + test("should show tooltip in the end if the mouse enters, leaves, and enters", function () { + $.support.transition = { end: 'fakeTransitionEnd' }; + var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') + .appendTo('#qunit-fixture') + .tooltip({ animation: true }) + stop() + tooltip.trigger('mouseenter') + setTimeout(function () { + tooltip.trigger('mouseout') + + setTimeout(function () { + tooltip.trigger('mouseenter') + + setTimeout(function () { + ok($(".tooltip").is(':visible'), 'tooltip is visible') + start() + tooltip.remove() + }, 1000) + }, 1) + }, 500) + }) + test("should destroy tooltip", function () { var tooltip = $('<div/>').tooltip().on('click.foo', function(){}) ok(tooltip.data('tooltip'), 'tooltip has data')