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

Commit bb329d2

Browse files
committed
refactor(tooltip): remove observer for triggers
1 parent d3a1aa3 commit bb329d2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/tooltip/test/tooltip.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ describe('tooltip', function() {
271271
expect( elmScope.tt_isOpen ).toBeFalsy();
272272
}));
273273

274-
it('should not share triggers among different element instances - issue 692', inject( function ($compile) {
274+
it('should only set up triggers once', inject( function ($compile) {
275275

276276
scope.test = true;
277277
elmBody = angular.element(
@@ -290,10 +290,12 @@ describe('tooltip', function() {
290290

291291
scope.$apply('test = false');
292292

293-
elm2.trigger('mouseenter');
293+
// click trigger isn't set
294+
elm2.click();
294295
expect( elmScope2.tt_isOpen ).toBeFalsy();
295296

296-
elm2.click();
297+
// mouseenter trigger is still set
298+
elm2.trigger('mouseenter');
297299
expect( elmScope2.tt_isOpen ).toBeTruthy();
298300
}));
299301
});

src/tooltip/tooltip.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
275275
element.unbind(triggers.hide, hideTooltipBind);
276276
};
277277

278-
attrs.$observe( prefix+'Trigger', function ( val ) {
278+
function prepTriggers() {
279+
var val = attrs[ prefix + 'Trigger' ];
279280
unregisterTriggers();
280281

281282
triggers = getTriggers( val );
@@ -286,7 +287,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
286287
element.bind( triggers.show, showTooltipBind );
287288
element.bind( triggers.hide, hideTooltipBind );
288289
}
289-
});
290+
}
291+
prepTriggers();
290292

291293
var animation = scope.$eval(attrs[prefix + 'Animation']);
292294
scope.tt_animation = angular.isDefined(animation) ? !!animation : options.animation;

0 commit comments

Comments
 (0)