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
This commit is contained in:
Georgios Kalpakas
2016-05-21 12:09:23 +03:00
committed by Peter Bacon Darwin
parent 1581827a51
commit 3f8efe73fc
3 changed files with 21 additions and 2 deletions
+2 -1
View File
@@ -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);
}
}
+18
View File
@@ -1880,6 +1880,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() {
+1 -1
View File
@@ -13,7 +13,7 @@ describe("animations", function() {
};
}));
afterEach(inject(function($$jqLite) {
afterEach(inject(function() {
dealoc(element);
}));