From 58e8ef4f87649910fc24d36f0db0fe80aa122d7e Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sat, 3 Aug 2013 12:59:28 +0200 Subject: [PATCH] fix(tooltip): triggers should be local to tooltip instances Closes #692 --- src/tooltip/test/tooltip.spec.js | 26 ++++++++++++++++++++++++++ src/tooltip/tooltip.js | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index b5c9c35b17..ae4179caac 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -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( + '
' + + '' + + '' + + '
' + ); + + $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() { diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 96403d7f04..07039dce05 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -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(); @@ -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