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

Commit 60515ae

Browse files
committed
fix(tooltip): update tooltip content when empty
Closes #1348
1 parent 40b80c3 commit 60515ae

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/tooltip/test/tooltip2.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ describe('tooltip directive', function () {
7070
$timeout.flush();
7171
expect(fragment).not.toHaveOpenTooltips();
7272
});
73+
74+
it('should update tooltip when its content becomes empty', function () {
75+
$rootScope.content = 'some text';
76+
var fragment = compileTooltip('<span tooltip="{{ content }}"></span>');
77+
78+
$rootScope.content = '';
79+
$rootScope.$digest();
80+
81+
fragment.find('span').trigger( 'mouseenter' );
82+
expect(fragment).not.toHaveOpenTooltips();
83+
});
7384
});
7485

7586
describe('option by option', function () {

src/tooltip/tooltip.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
247247
* Observe the relevant attributes.
248248
*/
249249
attrs.$observe( type, function ( val ) {
250-
if (val) {
251-
scope.tt_content = val;
252-
} else {
253-
if ( scope.tt_isOpen ) {
254-
hide();
255-
}
250+
scope.tt_content = val;
251+
252+
if (!val && scope.tt_isOpen ) {
253+
hide();
256254
}
257255
});
258256

0 commit comments

Comments
 (0)