Skip to content

Commit

Permalink
fix(tooltip): isOpen to work with expressions
Browse files Browse the repository at this point in the history
The is-open attribute should work with expressions
as well as model values

Closes angular-ui#4380
Fixes angular-ui#4362
  • Loading branch information
RobJacobs authored and jasonaden committed Sep 30, 2015
1 parent 92fb6bf commit 4e74ee3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/tooltip/test/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<span tooltip="tooltip text" tooltip-is-open="isOpen === true" >Selector Text</span>'
))(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;

Expand Down
4 changes: 2 additions & 2 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 4e74ee3

Please sign in to comment.