Chromium Code Reviews| Index: site/try/src/shadow_root.dart |
| =================================================================== |
| --- site/try/src/shadow_root.dart (revision 38889) |
| +++ site/try/src/shadow_root.dart (working copy) |
| @@ -49,6 +49,16 @@ |
| return '$buffer'; |
| } |
| +/// Element.contains(n) doesn't work when n is node(Text) in IE, |
| +/// so this is brute-force implementation of contains. |
|
ahe
2014/08/19 09:22:30
so this is *a* ...
aam-me
2014/08/19 12:09:13
Done.
|
| +bool containsNode(parent, child) { |
| + var p = child; |
|
ahe
2014/08/19 09:22:30
Indentation.
aam-me
2014/08/19 12:09:13
Done.
|
| + while (p != null && p != parent) { |
| + p = p.parentNode; |
| + } |
| + return p != null; |
| +} |
| + |
| /// Position [walker] at the last predecessor (that is, child of child of |
| /// child...) of [node]. The next call to walker.nextNode will return the first |
| /// node after [node]. |
| @@ -60,7 +70,7 @@ |
| for (Node current = walker.nextNode(); |
| current != null; |
| current = walker.nextNode()) { |
| - if (!node.contains(current)) { |
| + if (!containsNode(node, current)) { |
| walker.previousNode(); |
| return; |
| } |
| @@ -77,18 +87,19 @@ |
| node is Element && |
| node.getAttribute('try-dart-shadow-root') != null) { |
| skip(node, walker); |
| + } else { |
| + int action = f(node); |
| + switch (action) { |
| + case WALKER_RETURN: |
| + return; |
| + case WALKER_SKIP_NODE: |
| + skip(node, walker); |
| + break; |
| + case WALKER_NEXT: |
| + break; |
| + default: |
| + throw 'Unexpected action returned from [f]: $action'; |
| + } |
| } |
| - int action = f(node); |
| - switch (action) { |
| - case WALKER_RETURN: |
| - return; |
| - case WALKER_SKIP_NODE: |
| - skip(node, walker); |
| - break; |
| - case WALKER_NEXT: |
| - break; |
| - default: |
| - throw 'Unexpected action returned from [f]: $action'; |
| - } |
| } |
| } |