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

Commit c2ace47

Browse files
chrisirhcwesleycho
authored andcommitted
fix(popover): animations with ngAnimate
- Animations didn't work because the class attribute was mangled during compilation due to the way class attributes are merged on directives with `replace: true` - Rename attribute to popup-class - Refactor to rename variables named "class" as it's a keyword and also looks weird in editors Closes #3509 Fixes #3375 Fixes #3506
1 parent e31fcf0 commit c2ace47

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

src/popover/test/popover.spec.js

+24
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,30 @@ describe('popover', function() {
6868
elm.click();
6969
expect(scope.clicked).toBeTruthy();
7070
}));
71+
72+
it('should popup with animate class by default', inject(function() {
73+
elm.trigger( 'click' );
74+
expect( tooltipScope.isOpen ).toBe( true );
75+
76+
expect(elmBody.children().eq(1)).toHaveClass('fade');
77+
}));
78+
79+
it('should popup without animate class when animation disabled', inject(function($compile) {
80+
elmBody = angular.element(
81+
'<div><span popover="popover text" popover-animation="false">Selector Text</span></div>'
82+
);
83+
84+
$compile(elmBody)(scope);
85+
scope.$digest();
86+
elm = elmBody.find('span');
87+
elmScope = elm.scope();
88+
tooltipScope = elmScope.$$childTail;
89+
90+
elm.trigger( 'click' );
91+
expect( tooltipScope.isOpen ).toBe( true );
92+
expect(elmBody.children().eq(1)).not.toHaveClass('fade');
93+
}));
94+
7195
});
7296

7397

src/tooltip/tooltip.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
101101
'content="'+startSym+'content'+endSym+'" '+
102102
'content-exp="contentExp()" '+
103103
'placement="'+startSym+'placement'+endSym+'" '+
104-
'class="'+startSym+'class'+endSym+'" '+
104+
'popup-class="'+startSym+'popupClass'+endSym+'" '+
105105
'animation="animation" '+
106106
'is-open="isOpen"'+
107107
'origin-scope="origScope" '+
@@ -292,7 +292,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
292292
});
293293

294294
attrs.$observe( prefix+'Class', function ( val ) {
295-
ttScope.class = val;
295+
ttScope.popupClass = val;
296296
});
297297

298298
function prepPlacement() {
@@ -451,7 +451,7 @@ function ($animate , $sce , $compile , $templateRequest) {
451451
return {
452452
restrict: 'EA',
453453
replace: true,
454-
scope: { content: '@', placement: '@', class: '@', animation: '&', isOpen: '&' },
454+
scope: { content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
455455
templateUrl: 'template/tooltip/tooltip-popup.html'
456456
};
457457
})
@@ -478,7 +478,7 @@ function ($animate , $sce , $compile , $templateRequest) {
478478
return {
479479
restrict: 'EA',
480480
replace: true,
481-
scope: { contentExp: '&', placement: '@', class: '@', animation: '&', isOpen: '&' },
481+
scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
482482
templateUrl: 'template/tooltip/tooltip-html-popup.html'
483483
};
484484
})
@@ -494,7 +494,7 @@ Deprecated
494494
return {
495495
restrict: 'EA',
496496
replace: true,
497-
scope: { content: '@', placement: '@', class: '@', animation: '&', isOpen: '&' },
497+
scope: { content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
498498
templateUrl: 'template/tooltip/tooltip-html-unsafe-popup.html'
499499
};
500500
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="tooltip {{placement}} {{class}}" ng-class="{ in: isOpen(), fade: animation() }">
1+
<div class="tooltip {{placement}} {{popupClass}}" ng-class="{ in: isOpen(), fade: animation() }">
22
<div class="tooltip-arrow"></div>
33
<div class="tooltip-inner" ng-bind-html="contentExp()"></div>
44
</div>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="tooltip {{placement}} {{class}}" ng-class="{ in: isOpen(), fade: animation() }">
1+
<div class="tooltip {{placement}} {{popupClass}}" ng-class="{ in: isOpen(), fade: animation() }">
22
<div class="tooltip-arrow"></div>
33
<div class="tooltip-inner" bind-html-unsafe="content"></div>
44
</div>

template/tooltip/tooltip-popup.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="tooltip {{placement}} {{class}}" ng-class="{ in: isOpen(), fade: animation() }">
1+
<div class="tooltip {{placement}} {{popupClass}}" ng-class="{ in: isOpen(), fade: animation() }">
22
<div class="tooltip-arrow"></div>
33
<div class="tooltip-inner" ng-bind="content"></div>
44
</div>

0 commit comments

Comments
 (0)