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

Commit

Permalink
fix(ngAnimate): allow animations on body and root elements
Browse files Browse the repository at this point in the history
Closes #11956
Closes #12245
  • Loading branch information
OlenDavis authored and matsko committed Jul 17, 2015
1 parent 2ff1b09 commit 44ce9c8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ngAnimate/animateQueue.js
Expand Up @@ -523,8 +523,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
}

function areAnimationsAllowed(element, parentElement, event) {
var bodyElementDetected = false;
var rootElementDetected = false;
var bodyElementDetected = isMatchingElement(element, $$body) || element[0].nodeName === 'HTML';
var rootElementDetected = isMatchingElement(element, $rootElement);
var parentAnimationDetected = false;
var animateChildren;

Expand Down
28 changes: 28 additions & 0 deletions test/ngAnimate/animateSpec.js
Expand Up @@ -1227,6 +1227,34 @@ describe("animations", function() {
});
});

they('should allow an animation to run on the $prop element', ['$rootElement', 'body'], function(name) {
var capturedAnimation;

module(function($provide) {
$provide.factory('$rootElement', function($document) {
return jqLite($document[0].querySelector('html'));
});
$provide.factory('$$animation', function($$AnimateRunner) {
return function(element, method, options) {
capturedAnimation = arguments;
return new $$AnimateRunner();
};
});
});
inject(function($animate, $rootScope, $document, $rootElement) {
$animate.enabled(true);

var body = jqLite($document[0].body);
var targetElement = name === 'body' ? body : $rootElement;

$animate.addClass(targetElement, 'red');
$rootScope.$digest();

expect(capturedAnimation[0]).toBe(targetElement);
expect(capturedAnimation[1]).toBe('addClass');
});
});

describe('[ng-animate-children]', function() {
var parent, element, child, capturedAnimation, captureLog;
beforeEach(module(function($provide) {
Expand Down

0 comments on commit 44ce9c8

Please sign in to comment.