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

Commit 21b76ae

Browse files
gkalpakpetebacondarwin
authored andcommitted
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
1 parent 363fb16 commit 21b76ae

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/ngAnimate/animation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
378378
}
379379

380380
function update(element) {
381-
getRunner(element).setHost(newRunner);
381+
var runner = getRunner(element);
382+
if (runner) runner.setHost(newRunner);
382383
}
383384
}
384385

test/ngAnimate/animateCssSpec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,24 @@ describe("ngAnimate $animateCss", function() {
18791879
expect(element).not.toHaveClass('ng-leave-active');
18801880
expect(element).not.toHaveClass('ng-move-active');
18811881
}));
1882+
1883+
it('should not break when running anchored animations without duration',
1884+
inject(function($animate, $document, $rootElement) {
1885+
var element1 = jqLite('<div class="item" ng-animate-ref="test">Item 1</div>');
1886+
var element2 = jqLite('<div class="item" ng-animate-ref="test">Item 2</div>');
1887+
1888+
jqLite($document[0].body).append($rootElement);
1889+
$rootElement.append(element1);
1890+
1891+
expect($rootElement.text()).toBe('Item 1');
1892+
1893+
$animate.leave(element1);
1894+
$animate.enter(element2, $rootElement);
1895+
$animate.flush();
1896+
1897+
expect($rootElement.text()).toBe('Item 2');
1898+
})
1899+
);
18821900
});
18831901

18841902
describe("class-based animations", function() {

test/ngAnimate/animateSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("animations", function() {
1313
};
1414
}));
1515

16-
afterEach(inject(function($$jqLite) {
16+
afterEach(inject(function() {
1717
dealoc(element);
1818
}));
1919

0 commit comments

Comments
 (0)