From 976cd036da4cef4649b7c41a866fd89ad30f9abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Mon, 29 Jun 2015 23:02:54 -0400 Subject: [PATCH] chore(core): introduce $$body service This patch makes it easier to gain access to document.body via the injector. --- angularFiles.js | 1 + src/ngAnimate/body.js | 7 +++++++ src/ngAnimate/module.js | 3 +++ test/ngAnimate/bodySpec.js | 9 +++++++++ 4 files changed, 20 insertions(+) create mode 100644 src/ngAnimate/body.js create mode 100644 test/ngAnimate/bodySpec.js diff --git a/angularFiles.js b/angularFiles.js index 59bed0b138cd..f193ce6cf966 100755 --- a/angularFiles.js +++ b/angularFiles.js @@ -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', diff --git a/src/ngAnimate/body.js b/src/ngAnimate/body.js new file mode 100644 index 000000000000..8c8ce21ac9e8 --- /dev/null +++ b/src/ngAnimate/body.js @@ -0,0 +1,7 @@ +'use strict'; + +function $$BodyProvider() { + this.$get = ['$document', function($document) { + return jqLite($document[0].body); + }]; +} diff --git a/src/ngAnimate/module.js b/src/ngAnimate/module.js index bf6aa07644d1..71f20da8e406 100644 --- a/src/ngAnimate/module.js +++ b/src/ngAnimate/module.js @@ -2,6 +2,7 @@ /* global angularAnimateModule: true, + $$BodyProvider, $$rAFMutexFactory, $$rAFSchedulerFactory, $$AnimateChildrenDirective, @@ -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) diff --git a/test/ngAnimate/bodySpec.js b/test/ngAnimate/bodySpec.js new file mode 100644 index 000000000000..f87dabf1e355 --- /dev/null +++ b/test/ngAnimate/bodySpec.js @@ -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)); + })); +});