Skip to content

Commit 181acf7

Browse files
matskonetman92
authored andcommitted
chore(core): introduce $$body service
This patch makes it easier to gain access to document.body via the injector.
1 parent b50029f commit 181acf7

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

angularFiles.js

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ var angularFiles = {
8888
'angularModules': {
8989
'ngAnimate': [
9090
'src/ngAnimate/shared.js',
91+
'src/ngAnimate/body.js',
9192
'src/ngAnimate/rafScheduler.js',
9293
'src/ngAnimate/animateChildrenDirective.js',
9394
'src/ngAnimate/animateCss.js',

src/ngAnimate/body.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
function $$BodyProvider() {
4+
this.$get = ['$document', function($document) {
5+
return jqLite($document[0].body);
6+
}];
7+
}

src/ngAnimate/module.js

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

33
/* global angularAnimateModule: true,
44
5+
$$BodyProvider,
56
$$rAFMutexFactory,
67
$$rAFSchedulerFactory,
78
$$AnimateChildrenDirective,
@@ -741,6 +742,8 @@
741742
* Click here {@link ng.$animate $animate to learn more about animations with `$animate`}.
742743
*/
743744
angular.module('ngAnimate', [])
745+
.provider('$$body', $$BodyProvider)
746+
744747
.directive('ngAnimateChildren', $$AnimateChildrenDirective)
745748

746749
.factory('$$rAFMutex', $$rAFMutexFactory)

test/ngAnimate/bodySpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
describe('$$body', function() {
4+
beforeEach(module('ngAnimate'));
5+
6+
it("should inject $document", inject(function($$body, $document) {
7+
expect($$body).toEqual(jqLite($document[0].body));
8+
}));
9+
});

0 commit comments

Comments
 (0)