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

Commit 3f8efe7

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 1581827 commit 3f8efe7

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/ngAnimate/animation.js

+2-1
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

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

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

test/ngAnimate/animateSpec.js

+1-1
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)