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

Commit 13b5cd9

Browse files
committed
refactor(tooltip): lazily evaluate placement, delay
There's no need for an observer here because these values are only used on initialization of the tooltip.
1 parent eab6daf commit 13b5cd9

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/tooltip/tooltip.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
146146
if(hasEnableExp && !scope.$eval(attrs[prefix+'Enable'])) {
147147
return;
148148
}
149+
150+
prepareTooltip();
151+
149152
if ( scope.tt_popupDelay ) {
150153
// Do nothing if the tooltip was already scheduled to pop-up.
151154
// This happens if show is triggered multiple times before any hide is triggered.
@@ -242,6 +245,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
242245
}
243246
}
244247

248+
function prepareTooltip() {
249+
prepPlacement();
250+
prepPopupDelay();
251+
}
252+
245253
/**
246254
* Observe the relevant attributes.
247255
*/
@@ -257,14 +265,16 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
257265
scope.tt_title = val;
258266
});
259267

260-
attrs.$observe( prefix+'Placement', function ( val ) {
268+
function prepPlacement() {
269+
var val = attrs[ prefix + 'Placement' ];
261270
scope.tt_placement = angular.isDefined( val ) ? val : options.placement;
262-
});
271+
}
263272

264-
attrs.$observe( prefix+'PopupDelay', function ( val ) {
273+
function prepPopupDelay() {
274+
var val = attrs[ prefix + 'PopupDelay' ];
265275
var delay = parseInt( val, 10 );
266276
scope.tt_popupDelay = ! isNaN(delay) ? delay : options.popupDelay;
267-
});
277+
}
268278

269279
var unregisterTriggers = function () {
270280
element.unbind(triggers.show, showTooltipBind);

0 commit comments

Comments
 (0)