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

Commit

Permalink
fix(tooltip): add safety to $apply
Browse files Browse the repository at this point in the history
- Change to use `$rootScope.$digest()` only as necessary for safety

Closes #3943
Closes #4150
Fixes #516
  • Loading branch information
wesleycho committed Aug 8, 2015
1 parent 895a228 commit 22b16f0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
* Returns the actual instance of the $tooltip service.
* TODO support multiple triggers
*/
this.$get = [ '$window', '$compile', '$timeout', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $document, $position, $interpolate ) {
this.$get = [ '$window', '$compile', '$timeout', '$document', '$position', '$interpolate', '$rootScope', function ( $window, $compile, $timeout, $document, $position, $interpolate, $rootScope ) {
return function $tooltip ( type, prefix, defaultTriggerShow, options ) {
options = angular.extend( {}, defaultOptions, globalOptions, options );

Expand Down Expand Up @@ -179,9 +179,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
}

function hideTooltipBind () {
scope.$apply(function () {
hide();
});
hide();
if (!$rootScope.$$phase) {
$rootScope.$digest();
}
}

// Show the tooltip popup element.
Expand Down

0 comments on commit 22b16f0

Please sign in to comment.