Skip to content
Permalink
Browse files

fix($animate): don't break on anchored animations without duration

If the `from` element of an animation does not actually have an animation
then there will be no animation runner on that element. This is possible
if the element has the `ng-animate-ref` attribute but does not have any
CSS animations or transitions defined.

In this case, it is not necessary to try to update the host of the
non-existent runner.

Fixes #14641
Closes #14645
  • Loading branch information
gkalpak authored and petebacondarwin committed May 21, 2016
1 parent 363fb16 commit 21b76aed06d9cc04bd25a99c23ba852af782b357
Showing with 21 additions and 2 deletions.
  1. +2 −1 src/ngAnimate/animation.js
  2. +18 −0 test/ngAnimate/animateCssSpec.js
  3. +1 −1 test/ngAnimate/animateSpec.js
@@ -378,7 +378,8 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
}

function update(element) {
getRunner(element).setHost(newRunner);
var runner = getRunner(element);
if (runner) runner.setHost(newRunner);
}
}

@@ -1879,6 +1879,24 @@ describe("ngAnimate $animateCss", function() {
expect(element).not.toHaveClass('ng-leave-active');
expect(element).not.toHaveClass('ng-move-active');
}));

it('should not break when running anchored animations without duration',
inject(function($animate, $document, $rootElement) {
var element1 = jqLite('<div class="item" ng-animate-ref="test">Item 1</div>');
var element2 = jqLite('<div class="item" ng-animate-ref="test">Item 2</div>');

jqLite($document[0].body).append($rootElement);
$rootElement.append(element1);

expect($rootElement.text()).toBe('Item 1');

$animate.leave(element1);
$animate.enter(element2, $rootElement);
$animate.flush();

expect($rootElement.text()).toBe('Item 2');
})
);
});

describe("class-based animations", function() {
@@ -13,7 +13,7 @@ describe("animations", function() {
};
}));

afterEach(inject(function($$jqLite) {
afterEach(inject(function() {
dealoc(element);
}));

0 comments on commit 21b76ae

Please sign in to comment.
You can’t perform that action at this time.