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

Infinite digest loop when using filters inside tooltip expression properties (like popover-html) #4429

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,27 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
var ttScope = scope.$new(true);
var repositionScheduled = false;
var isOpenExp = angular.isDefined(attrs[prefix + 'IsOpen']) ? $parse(attrs[prefix + 'IsOpen']) : false;

var contentExpVal;
var contentExpGetter;
var contentExpGetterStartWatch;
var contentExpGetterStopWatch;

if(options.useContentExp){
contentExpGetter = $parse(attrs[type]);

contentExpGetterStartWatch = function(){
if(contentExpGetterStopWatch){
contentExpGetterStopWatch();
}
contentExpGetterStopWatch = scope.$watch(contentExpGetter,function(val){
contentExpVal = val;
if (!val && ttScope.isOpen) {
hide();
}
});
};
}

var positionTooltip = function() {
// check if tooltip exists and is not empty
if (!tooltip || !tooltip.html()) { return; }
Expand Down Expand Up @@ -231,7 +251,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
}

// Don't show empty tooltips.
if (!(options.useContentExp ? ttScope.contentExp() : ttScope.content)) {
if (!(options.useContentExp ? contentExpGetter(scope) : ttScope.content)) {
return angular.noop;
}

Expand Down Expand Up @@ -296,11 +316,9 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
});

if (options.useContentExp) {
tooltipLinkedScope.$watch('contentExp()', function(val) {
if (!val && ttScope.isOpen) {
hide();
}
});
if(!contentExpGetterStopWatch){
contentExpGetterStartWatch();
}

tooltipLinkedScope.$watch(function() {
if (!repositionScheduled) {
Expand All @@ -323,6 +341,10 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
tooltip.remove();
tooltip = null;
}
if(contentExpGetterStopWatch){
contentExpGetterStopWatch();
contentExpGetterStopWatch = null;
}
if (tooltipLinkedScope) {
tooltipLinkedScope.$destroy();
tooltipLinkedScope = null;
Expand All @@ -336,7 +358,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
}

ttScope.contentExp = function() {
return scope.$eval(attrs[type]);
return contentExpVal;
};

/**
Expand Down