From 98d825e10d3bf76f47e69abba857a8933c8cb7d9 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Mon, 10 Mar 2014 19:32:09 -0400 Subject: fix(jqLite): traverse `host` property for DocumentFragment in inheritedData() If dealing with a document fragment node with a host element, and no parent, use the host element as the parent. This enables directives within a Shadow DOM or polyfilled Shadow DOM to lookup parent controllers. Closes #6637 --- src/jqLite.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/jqLite.js b/src/jqLite.js index ba613f21..738f47a9 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -364,11 +364,15 @@ function jqLiteInheritedData(element, name, value) { var names = isArray(name) ? name : [name]; while (element.length) { - + var node = element[0]; for (var i = 0, ii = names.length; i < ii; i++) { if ((value = element.data(names[i])) !== undefined) return value; } - element = element.parent(); + + // If dealing with a document fragment node with a host element, and no parent, use the host + // element as the parent. This enables directives within a Shadow DOM or polyfilled Shadow DOM + // to lookup parent controllers. + element = jqLite(node.parentNode || (node.nodeType === 11 && node.host)); } } -- cgit v1.2.3 class='tabs'> aboutsummaryrefslogtreecommitdiffstats
path: root/example/personalLog/personalLog.html
blob: 483a37b8371bf4e955e83067f0980cd9ad55a507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!doctype html>
<html ng-app="personalLog">
  <head>
    <title>Personal Log</title>
    <script src="../../src/loader.js"></script>
    <script>
      setupModuleLoader(window);
    </script>
    <script src="personalLog.js"></script>
    <script src="../../src/angular-bootstrap.js"></script>
    <script src="../../src/ngCookies/cookies.js"></script>
  </head>


  <body ng-controller="LogCtrl">

    <form action="" ng-submit="addLog(newMsg)">
      <input type="text" ng-model="newMsg">
      <input type="submit" value="add">
      <input type="button" value="remove all" ng-click="rmLogs()">
    </form>

    <hr/>
    <h2>Logs:</h2>
    <ul>
      <li ng-repeat="log in logs | orderBy:'-at'">
        {{log.at | date:'yy-MM-dd HH:mm'}} {{log.msg}}
        [<a href="" ng-click="rmLog(log)">x</a>]
      </li>
    </ul>

  </body>
</html>