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

fix($animate): ensure no transitions are applied when an empty inline style object is provided #10770

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ angular.module('ngAnimate', ['ng'])
return;
}

if (!staggerTime && styles) {
if (!staggerTime && styles && Object.keys(styles).length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that styles could be a string? If so then calling Object.keys would throw an exception.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I think it cannot since in $animate.animate(element, from, to, ...) from and to are both supposed to be objects.

if (!timings.transitionDuration) {
element.css('transition', timings.animationDuration + 's linear all');
appliedStyles.push('transition');
Expand Down
19 changes: 19 additions & 0 deletions test/ngAnimate/animateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,25 @@ describe("ngAnimate", function() {
expect(element.attr('style')).toContain('border-color: blue');
}));

it("should not apply a piggy-back-transition if the styles object contains no styles",
inject(function($compile, $animate, $rootScope, $sniffer) {

if (!$sniffer.animations) return;

$animate.enabled(true);
ss.addRule('.on', '-webkit-animation: 1s super-animation; animation: 1s super-animation;');

element = $compile(html('<div>1</div>'))($rootScope);

$animate.addClass(element, 'on', {
to: {}
});

$rootScope.$digest();
$animate.triggerReflow();
expect(element.attr('style')).not.toMatch(/transition/);
}));

it("should pause the playstate when performing a stagger animation",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {

Expand Down