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

Commit 0d940ad

Browse files
OlenDavismatsko
authored andcommitted
fix(ngAnimate): allow animations on body and root elements
Closes #11956
1 parent 3c37b5e commit 0d940ad

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
@@ -522,8 +522,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
522522
}
523523

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

test/ngAnimate/animateSpec.js

+28
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,34 @@ describe("animations", function() {
12091209
});
12101210
});
12111211

1212+
they('should allow an animation to run on the $prop element', ['$rootElement', 'body'], function(name) {
1213+
var capturedAnimation;
1214+
1215+
module(function($provide) {
1216+
$provide.factory('$rootElement', function($document) {
1217+
return jqLite($document[0].querySelector('html'));
1218+
});
1219+
$provide.factory('$$animation', function($$AnimateRunner) {
1220+
return function(element, method, options) {
1221+
capturedAnimation = arguments;
1222+
return new $$AnimateRunner();
1223+
};
1224+
});
1225+
});
1226+
inject(function($animate, $rootScope, $document, $rootElement) {
1227+
$animate.enabled(true);
1228+
1229+
var body = jqLite($document[0].body);
1230+
var targetElement = name === 'body' ? body : $rootElement;
1231+
1232+
$animate.addClass(targetElement, 'red');
1233+
$rootScope.$digest();
1234+
1235+
expect(capturedAnimation[0]).toBe(targetElement);
1236+
expect(capturedAnimation[1]).toBe('addClass');
1237+
});
1238+
});
1239+
12121240
describe('[ng-animate-children]', function() {
12131241
var parent, element, child, capturedAnimation, captureLog;
12141242
beforeEach(module(function($provide) {

0 commit comments

Comments
 (0)