diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index f0bd321a6d..d8d808f397 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -350,6 +350,28 @@ describe('tooltip', function() { }); }); + describe('with an is-open attribute expression', function() { + beforeEach(inject(function ($compile) { + scope.isOpen = false; + elm = $compile(angular.element( + 'Selector Text' + ))(scope); + elmScope = elm.scope(); + tooltipScope = elmScope.$$childTail; + scope.$digest(); + })); + + it('should show and hide with the expression', function() { + expect(tooltipScope.isOpen).toBe(false); + elmScope.isOpen = true; + elmScope.$digest(); + expect(tooltipScope.isOpen).toBe(true); + elmScope.isOpen = false; + elmScope.$digest(); + expect(tooltipScope.isOpen).toBe(false); + }); + }); + describe('with a trigger attribute', function() { var scope, elmBody, elm, elmScope; diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 4fbddcdc81..1c266ca7fd 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -221,7 +221,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position']) // And show the tooltip. ttScope.isOpen = true; - if (isOpenExp) { + if (isOpenExp && angular.isFunction(isOpenExp.assign)) { isOpenExp.assign(ttScope.origScope, ttScope.isOpen); } @@ -240,7 +240,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position']) // First things first: we don't show it anymore. ttScope.isOpen = false; - if (isOpenExp) { + if (isOpenExp && angular.isFunction(isOpenExp.assign)) { isOpenExp.assign(ttScope.origScope, ttScope.isOpen); }