aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2012-03-21 15:16:41 -0700
committerIgor Minar2012-03-22 16:39:36 -0700
commit5fdab52dd7c269f99839f4fa6b5854d9548269fa (patch)
tree755a94326f85edffeef87425a04f0bb20e2f18e7 /src
parent541bedd1a9692208deae0cd2a93171e87fb7d1ba (diff)
downloadangular.js-5fdab52dd7c269f99839f4fa6b5854d9548269fa.tar.bz2
feat(jqLite): make injector() and scope() work with the document object
For typical app that has ng-app directive on the html element, we now can do: angular.element(document).injector() or .injector() angular.element(document).scope() or .scope() instead of: angular.element(document.getElementsByTagName('html')[0]).injector() ...
Diffstat (limited to 'src')
-rw-r--r--src/jqLite.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/jqLite.js b/src/jqLite.js
index 79f22e62..007deaa8 100644
--- a/src/jqLite.js
+++ b/src/jqLite.js
@@ -279,6 +279,13 @@ function JQLiteController(element, name) {
function JQLiteInheritedData(element, name, value) {
element = jqLite(element);
+
+ // if element is the document object work with the html element instead
+ // this makes $(document).scope() possible
+ if(element[0].nodeType == 9) {
+ element = element.find('html');
+ }
+
while (element.length) {
if (value = element.data(name)) return value;
element = element.parent();