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

Commit 44ce9c8

Browse files
OlenDavismatsko
authored andcommitted
fix(ngAnimate): allow animations on body and root elements
Closes #11956 Closes #12245
1 parent 2ff1b09 commit 44ce9c8

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/ngAnimate/animateQueue.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
523523
}
524524

525525
function areAnimationsAllowed(element, parentElement, event) {
526-
var bodyElementDetected = false;
527-
var rootElementDetected = false;
526+
var bodyElementDetected = isMatchingElement(element, $$body) || element[0].nodeName === 'HTML';
527+
var rootElementDetected = isMatchingElement(element, $rootElement);
528528
var parentAnimationDetected = false;
529529
var animateChildren;
530530

test/ngAnimate/animateSpec.js

+28
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,34 @@ describe("animations", function() {
12271227
});
12281228
});
12291229

1230+
they('should allow an animation to run on the $prop element', ['$rootElement', 'body'], function(name) {
1231+
var capturedAnimation;
1232+
1233+
module(function($provide) {
1234+
$provide.factory('$rootElement', function($document) {
1235+
return jqLite($document[0].querySelector('html'));
1236+
});
1237+
$provide.factory('$$animation', function($$AnimateRunner) {
1238+
return function(element, method, options) {
1239+
capturedAnimation = arguments;
1240+
return new $$AnimateRunner();
1241+
};
1242+
});
1243+
});
1244+
inject(function($animate, $rootScope, $document, $rootElement) {
1245+
$animate.enabled(true);
1246+
1247+
var body = jqLite($document[0].body);
1248+
var targetElement = name === 'body' ? body : $rootElement;
1249+
1250+
$animate.addClass(targetElement, 'red');
1251+
$rootScope.$digest();
1252+
1253+
expect(capturedAnimation[0]).toBe(targetElement);
1254+
expect(capturedAnimation[1]).toBe('addClass');
1255+
});
1256+
});
1257+
12301258
describe('[ng-animate-children]', function() {
12311259
var parent, element, child, capturedAnimation, captureLog;
12321260
beforeEach(module(function($provide) {

0 commit comments

Comments
 (0)