Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(tooltip): update tooltip content when empty
Browse files Browse the repository at this point in the history
Closes #1348
  • Loading branch information
bekos committed Dec 9, 2013
1 parent 40b80c3 commit 60515ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/tooltip/test/tooltip2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<span tooltip="{{ content }}"></span>');

$rootScope.content = '';
$rootScope.$digest();

fragment.find('span').trigger( 'mouseenter' );
expect(fragment).not.toHaveOpenTooltips();
});
});

describe('option by option', function () {
Expand Down
10 changes: 4 additions & 6 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});

Expand Down

0 comments on commit 60515ae

Please sign in to comment.