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

Commit 64ef084

Browse files
committedSep 22, 2015
revert: chore(core): introduce $$body service
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
1 parent 8b27c3f commit 64ef084

12 files changed

+129
-148
lines changed
 

‎angularFiles.js

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ var angularFiles = {
9292
'angularModules': {
9393
'ngAnimate': [
9494
'src/ngAnimate/shared.js',
95-
'src/ngAnimate/body.js',
9695
'src/ngAnimate/rafScheduler.js',
9796
'src/ngAnimate/animateChildrenDirective.js',
9897
'src/ngAnimate/animateCss.js',

‎src/ngAnimate/animateCssDriver.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ var $$AnimateCssDriverProvider = ['$$animationProvider', function($$animationPro
99
var NG_OUT_ANCHOR_CLASS_NAME = 'ng-anchor-out';
1010
var NG_IN_ANCHOR_CLASS_NAME = 'ng-anchor-in';
1111

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

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

18-
var bodyNode = getDomNode($$body);
18+
var bodyNode = $document[0].body;
1919
var rootNode = getDomNode($rootElement);
2020

2121
var rootBodyElement = jqLite(bodyNode.parentNode === rootNode ? bodyNode : rootNode);

‎src/ngAnimate/animateQueue.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
6666
return (nO.addClass && nO.addClass === cO.removeClass) || (nO.removeClass && nO.removeClass === cO.addClass);
6767
});
6868

69-
this.$get = ['$$rAF', '$rootScope', '$rootElement', '$document', '$$body', '$$HashMap',
69+
this.$get = ['$$rAF', '$rootScope', '$rootElement', '$document', '$$HashMap',
7070
'$$animation', '$$AnimateRunner', '$templateRequest', '$$jqLite', '$$forceReflow',
71-
function($$rAF, $rootScope, $rootElement, $document, $$body, $$HashMap,
71+
function($$rAF, $rootScope, $rootElement, $document, $$HashMap,
7272
$$animation, $$AnimateRunner, $templateRequest, $$jqLite, $$forceReflow) {
7373

7474
var activeAnimationsLookup = new $$HashMap();
@@ -528,7 +528,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
528528
}
529529

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

590591
parentElement = parentElement.parent();

‎src/ngAnimate/body.js

-7
This file was deleted.

‎src/ngAnimate/module.js

-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
/* global angularAnimateModule: true,
44
5-
$$BodyProvider,
65
$$AnimateAsyncRunFactory,
76
$$rAFSchedulerFactory,
87
$$AnimateChildrenDirective,
@@ -742,8 +741,6 @@
742741
* Click here {@link ng.$animate to learn more about animations with `$animate`}.
743742
*/
744743
angular.module('ngAnimate', [])
745-
.provider('$$body', $$BodyProvider)
746-
747744
.directive('ngAnimateChildren', $$AnimateChildrenDirective)
748745
.factory('$$rAFScheduler', $$rAFSchedulerFactory)
749746

‎test/ng/directive/ngClassSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,12 @@ describe('ngClass animations', function() {
468468
};
469469
});
470470
});
471-
inject(function($compile, $rootScope, $browser, $rootElement, $animate, $timeout, $$body) {
471+
inject(function($compile, $rootScope, $browser, $rootElement, $animate, $document) {
472472
$animate.enabled(true);
473473

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

478478
$compile(element)($rootScope);
479479

‎test/ngAnimate/animateCssDriverSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe("ngAnimate $$animateCssDriver", function() {
121121
var from, to, fromAnimation, toAnimation;
122122

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

132132
// we need to do this so that style detection works
133-
$$body.append($rootElement);
133+
jqLite($document[0].body).append($rootElement);
134134
};
135135
}));
136136

0 commit comments

Comments
 (0)
This repository has been archived.