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

Commit c0df320

Browse files
chrisirhcpkozlowski-opensource
authored andcommitted
fix(tooltip): performance and scope fixes
Isolate scope contents should be the same after hiding and showing the tooltip. The isolate scope's parent should also always be set to the directive's scope correctly. fix(tooltip): link on demand - Calling $digest is enough as we only need to digest the watchers in this scope and its children. No need to call $apply. - Set invokeApply to false on $timeout for popUpDelay - No need to test for cached reference when tooltip isn't visible as the tooltip has no scope. Closes #1450 Closes #1191 Closes #1455
1 parent c4d0e2a commit c0df320

File tree

2 files changed

+235
-195
lines changed

2 files changed

+235
-195
lines changed

src/tooltip/test/tooltip.spec.js

+27-8
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('tooltip', function() {
9898
scope.alt = "Alt Message";
9999

100100
elmBody = $compile( angular.element(
101-
'<div><span alt={{alt}} tooltip="{{tooltipMsg}}">Selector Text</span></div>'
101+
'<div><span alt={{alt}} tooltip="{{tooltipMsg}}" tooltip-animation="false">Selector Text</span></div>'
102102
) )( scope );
103103

104104
$compile( elmBody )( scope );
@@ -114,6 +114,13 @@ describe('tooltip', function() {
114114
expect( ttScope.content ).toBe( scope.tooltipMsg );
115115

116116
elm.trigger( 'mouseleave' );
117+
118+
//Isolate scope contents should be the same after hiding and showing again (issue 1191)
119+
elm.trigger( 'mouseenter' );
120+
121+
ttScope = angular.element( elmBody.children()[1] ).scope();
122+
expect( ttScope.placement ).toBe( 'top' );
123+
expect( ttScope.content ).toBe( scope.tooltipMsg );
117124
}));
118125

119126
it('should not show tooltips if there is nothing to show - issue #129', inject(function ($compile) {
@@ -136,6 +143,24 @@ describe('tooltip', function() {
136143
expect( elmBody.children().length ).toBe( 0 );
137144
}));
138145

146+
it('issue 1191 - isolate scope on the popup should always be child of correct element scope', inject( function ( $compile ) {
147+
var ttScope;
148+
elm.trigger( 'mouseenter' );
149+
150+
ttScope = angular.element( elmBody.children()[1] ).scope();
151+
expect( ttScope.$parent ).toBe( elmScope );
152+
153+
elm.trigger( 'mouseleave' );
154+
155+
// After leaving and coming back, the scope's parent should be the same
156+
elm.trigger( 'mouseenter' );
157+
158+
ttScope = angular.element( elmBody.children()[1] ).scope();
159+
expect( ttScope.$parent ).toBe( elmScope );
160+
161+
elm.trigger( 'mouseleave' );
162+
}));
163+
139164
describe('with specified enable expression', function() {
140165

141166
beforeEach(inject(function ($compile) {
@@ -323,18 +348,12 @@ describe('tooltip', function() {
323348

324349
elm = elmBody.find('input');
325350
elmScope = elm.scope();
351+
elm.trigger('fooTrigger');
326352
tooltipScope = elmScope.$$childTail;
327353
}));
328354

329-
it( 'should not contain a cached reference', function() {
330-
expect( inCache() ).toBeTruthy();
331-
elmScope.$destroy();
332-
expect( inCache() ).toBeFalsy();
333-
});
334-
335355
it( 'should not contain a cached reference when visible', inject( function( $timeout ) {
336356
expect( inCache() ).toBeTruthy();
337-
elm.trigger('fooTrigger');
338357
elmScope.$destroy();
339358
expect( inCache() ).toBeFalsy();
340359
}));

0 commit comments

Comments
 (0)