Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 0db5b21

Browse files
matskopetebacondarwin
authored andcommitted
fix($animate): ensure no transitions are applied when an empty inline style object is provided
Closes #10613 Closes #10770
1 parent c260e73 commit 0db5b21

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/ngAnimate/animate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ angular.module('ngAnimate', ['ng'])
18691869
return;
18701870
}
18711871

1872-
if (!staggerTime && styles) {
1872+
if (!staggerTime && styles && Object.keys(styles).length > 0) {
18731873
if (!timings.transitionDuration) {
18741874
element.css('transition', timings.animationDuration + 's linear all');
18751875
appliedStyles.push('transition');

test/ngAnimate/animateSpec.js

+19
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,25 @@ describe("ngAnimate", function() {
13811381
expect(element.attr('style')).toContain('border-color: blue');
13821382
}));
13831383

1384+
it("should not apply a piggy-back-transition if the styles object contains no styles",
1385+
inject(function($compile, $animate, $rootScope, $sniffer) {
1386+
1387+
if (!$sniffer.animations) return;
1388+
1389+
$animate.enabled(true);
1390+
ss.addRule('.on', '-webkit-animation: 1s super-animation; animation: 1s super-animation;');
1391+
1392+
element = $compile(html('<div>1</div>'))($rootScope);
1393+
1394+
$animate.addClass(element, 'on', {
1395+
to: {}
1396+
});
1397+
1398+
$rootScope.$digest();
1399+
$animate.triggerReflow();
1400+
expect(element.attr('style')).not.toMatch(/transition/);
1401+
}));
1402+
13841403
it("should pause the playstate when performing a stagger animation",
13851404
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
13861405

0 commit comments

Comments
 (0)