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

Commit

Permalink
revert: chore(core): introduce $$body service
Browse files Browse the repository at this point in the history
Relying on the body node to be present right at injection has
caused issues with unit testing as well as some animations on
the body element. Reverting this patch fixes these issues.

Closes #12874
  • Loading branch information
matsko committed Sep 22, 2015
1 parent 8b27c3f commit 64ef084
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 148 deletions.
1 change: 0 additions & 1 deletion angularFiles.js
Expand Up @@ -92,7 +92,6 @@ var angularFiles = {
'angularModules': {
'ngAnimate': [
'src/ngAnimate/shared.js',
'src/ngAnimate/body.js',
'src/ngAnimate/rafScheduler.js',
'src/ngAnimate/animateChildrenDirective.js',
'src/ngAnimate/animateCss.js',
Expand Down
6 changes: 3 additions & 3 deletions src/ngAnimate/animateCssDriver.js
Expand Up @@ -9,13 +9,13 @@ var $$AnimateCssDriverProvider = ['$$animationProvider', function($$animationPro
var NG_OUT_ANCHOR_CLASS_NAME = 'ng-anchor-out';
var NG_IN_ANCHOR_CLASS_NAME = 'ng-anchor-in';

this.$get = ['$animateCss', '$rootScope', '$$AnimateRunner', '$rootElement', '$$body', '$sniffer', '$$jqLite',
function($animateCss, $rootScope, $$AnimateRunner, $rootElement, $$body, $sniffer, $$jqLite) {
this.$get = ['$animateCss', '$rootScope', '$$AnimateRunner', '$rootElement', '$sniffer', '$$jqLite', '$document',
function($animateCss, $rootScope, $$AnimateRunner, $rootElement, $sniffer, $$jqLite, $document) {

// only browsers that support these properties can render animations
if (!$sniffer.animations && !$sniffer.transitions) return noop;

var bodyNode = getDomNode($$body);
var bodyNode = $document[0].body;
var rootNode = getDomNode($rootElement);

var rootBodyElement = jqLite(bodyNode.parentNode === rootNode ? bodyNode : rootNode);
Expand Down
9 changes: 5 additions & 4 deletions src/ngAnimate/animateQueue.js
Expand Up @@ -66,9 +66,9 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
return (nO.addClass && nO.addClass === cO.removeClass) || (nO.removeClass && nO.removeClass === cO.addClass);
});

this.$get = ['$$rAF', '$rootScope', '$rootElement', '$document', '$$body', '$$HashMap',
this.$get = ['$$rAF', '$rootScope', '$rootElement', '$document', '$$HashMap',
'$$animation', '$$AnimateRunner', '$templateRequest', '$$jqLite', '$$forceReflow',
function($$rAF, $rootScope, $rootElement, $document, $$body, $$HashMap,
function($$rAF, $rootScope, $rootElement, $document, $$HashMap,
$$animation, $$AnimateRunner, $templateRequest, $$jqLite, $$forceReflow) {

var activeAnimationsLookup = new $$HashMap();
Expand Down Expand Up @@ -528,7 +528,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
}

function areAnimationsAllowed(element, parentElement, event) {
var bodyElementDetected = isMatchingElement(element, $$body) || element[0].nodeName === 'HTML';
var bodyElement = jqLite($document[0].body);
var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';
var rootElementDetected = isMatchingElement(element, $rootElement);
var parentAnimationDetected = false;
var animateChildren;
Expand Down Expand Up @@ -584,7 +585,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
if (!bodyElementDetected) {
// we also need to ensure that the element is or will be apart of the body element
// otherwise it is pointless to even issue an animation to be rendered
bodyElementDetected = isMatchingElement(parentElement, $$body);
bodyElementDetected = isMatchingElement(parentElement, bodyElement);
}

parentElement = parentElement.parent();
Expand Down
7 changes: 0 additions & 7 deletions src/ngAnimate/body.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/ngAnimate/module.js
Expand Up @@ -2,7 +2,6 @@

/* global angularAnimateModule: true,
$$BodyProvider,
$$AnimateAsyncRunFactory,
$$rAFSchedulerFactory,
$$AnimateChildrenDirective,
Expand Down Expand Up @@ -742,8 +741,6 @@
* Click here {@link ng.$animate to learn more about animations with `$animate`}.
*/
angular.module('ngAnimate', [])
.provider('$$body', $$BodyProvider)

.directive('ngAnimateChildren', $$AnimateChildrenDirective)
.factory('$$rAFScheduler', $$rAFSchedulerFactory)

Expand Down
4 changes: 2 additions & 2 deletions test/ng/directive/ngClassSpec.js
Expand Up @@ -468,12 +468,12 @@ describe('ngClass animations', function() {
};
});
});
inject(function($compile, $rootScope, $browser, $rootElement, $animate, $timeout, $$body) {
inject(function($compile, $rootScope, $browser, $rootElement, $animate, $document) {
$animate.enabled(true);

$rootScope.val = 'crazy';
element = angular.element('<div ng-class="val"></div>');
$$body.append($rootElement);
jqLite($document[0].body).append($rootElement);

$compile(element)($rootScope);

Expand Down
4 changes: 2 additions & 2 deletions test/ngAnimate/animateCssDriverSpec.js
Expand Up @@ -121,7 +121,7 @@ describe("ngAnimate $$animateCssDriver", function() {
var from, to, fromAnimation, toAnimation;

beforeEach(module(function() {
return function($rootElement, $$body) {
return function($rootElement, $document) {
from = element;
to = jqLite('<div></div>');
fromAnimation = { element: from, event: 'enter' };
Expand All @@ -130,7 +130,7 @@ describe("ngAnimate $$animateCssDriver", function() {
$rootElement.append(to);

// we need to do this so that style detection works
$$body.append($rootElement);
jqLite($document[0].body).append($rootElement);
};
}));

Expand Down

0 comments on commit 64ef084

Please sign in to comment.