Skip to content

Commit

Permalink
chore(core): introduce $$body service
Browse files Browse the repository at this point in the history
This patch makes it easier to gain access to document.body
via the injector.
  • Loading branch information
matsko committed Jul 17, 2015
1 parent 21d6db3 commit 976cd03
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ 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
7 changes: 7 additions & 0 deletions src/ngAnimate/body.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

function $$BodyProvider() {
this.$get = ['$document', function($document) {
return jqLite($document[0].body);
}];
}
3 changes: 3 additions & 0 deletions src/ngAnimate/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

.directive('ngAnimateChildren', $$AnimateChildrenDirective)

.factory('$$rAFMutex', $$rAFMutexFactory)
Expand Down
9 changes: 9 additions & 0 deletions test/ngAnimate/bodySpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

describe('$$body', function() {
beforeEach(module('ngAnimate'));

it("should inject $document", inject(function($$body, $document) {
expect($$body).toEqual(jqLite($document[0].body));
}));
});

0 comments on commit 976cd03

Please sign in to comment.