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

Commit

Permalink
fix(tooltip): triggers should be local to tooltip instances
Browse files Browse the repository at this point in the history
Closes #692
  • Loading branch information
pkozlowski-opensource committed Aug 3, 2013
1 parent f45815c commit 58e8ef4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/tooltip/test/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,32 @@ describe('tooltip', function() {
elm.trigger('fakeTriggerAttr');
expect( elmScope.tt_isOpen ).toBeFalsy();
}));

it('should not share triggers among different element instances - issue 692', inject( function ($compile) {

scope.test = true;
elmBody = angular.element(
'<div>' +
'<input tooltip="Hello!" tooltip-trigger="{{ (test && \'mouseenter\' || \'click\') }}" />' +
'<input tooltip="Hello!" tooltip-trigger="{{ (test && \'mouseenter\' || \'click\') }}" />' +
'</div>'
);

$compile(elmBody)(scope);
scope.$apply();
var elm1 = elmBody.find('input').eq(0);
var elm2 = elmBody.find('input').eq(1);
var elmScope1 = elm1.scope();
var elmScope2 = elm2.scope();

scope.$apply('test = false');

elm2.trigger('mouseenter');
expect( elmScope2.tt_isOpen ).toBeFalsy();

elm2.click();
expect( elmScope2.tt_isOpen ).toBeTruthy();
}));
});

describe( 'with an append-to-body attribute', function() {
Expand Down
2 changes: 1 addition & 1 deletion src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
}

var directiveName = snake_case( type );
var triggers = setTriggers( undefined );

var startSym = $interpolate.startSymbol();
var endSym = $interpolate.endSymbol();
Expand All @@ -122,6 +121,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
var popupTimeout;
var $body;
var appendToBody = angular.isDefined( options.appendToBody ) ? options.appendToBody : false;
var triggers = setTriggers( undefined );

// By default, the tooltip is not open.
// TODO add ability to start tooltip opened
Expand Down

0 comments on commit 58e8ef4

Please sign in to comment.