diff --git a/src/tooltip/test/tooltip2.spec.js b/src/tooltip/test/tooltip2.spec.js index 6a1d93cfea..bb7e6ebba5 100644 --- a/src/tooltip/test/tooltip2.spec.js +++ b/src/tooltip/test/tooltip2.spec.js @@ -70,6 +70,17 @@ describe('tooltip directive', function () { $timeout.flush(); expect(fragment).not.toHaveOpenTooltips(); }); + + it('should update tooltip when its content becomes empty', function () { + $rootScope.content = 'some text'; + var fragment = compileTooltip(''); + + $rootScope.content = ''; + $rootScope.$digest(); + + fragment.find('span').trigger( 'mouseenter' ); + expect(fragment).not.toHaveOpenTooltips(); + }); }); describe('option by option', function () { diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 987cb410dc..a72d5295af 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -247,12 +247,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap * Observe the relevant attributes. */ attrs.$observe( type, function ( val ) { - if (val) { - scope.tt_content = val; - } else { - if ( scope.tt_isOpen ) { - hide(); - } + scope.tt_content = val; + + if (!val && scope.tt_isOpen ) { + hide(); } });