Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit ccede3b

Browse files
committed
feat(testability): findBindings and findModels should descend into the ShadowDOM
Note that this won't work for you unless you have a chromedriver build that works with the shadow DOM.
1 parent f3f013b commit ccede3b

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

example/web/animation/repeat_demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ part of animation;
22

33
@Component(
44
selector: 'repeat-demo',
5-
useShadowDom: false,
5+
useShadowDom: true,
66
template: '''
77
<div class="repeat-demo">
88
<button ng-click="ctrl.addItem()">Add Thing</button>

example/web/animation/visibility_demo.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ part of animation;
1616
</div>
1717
</div>
1818
''',
19-
publishAs: 'ctrl',
20-
useShadowDom: false)
19+
publishAs: 'ctrl')
2120
class VisibilityDemo {
2221
bool visible = false;
2322
}

lib/introspection.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ ElementProbe _findProbeWalkingUp(dom.Node node, [dom.Node ascendUntil]) {
2828
while (node != null && node != ascendUntil) {
2929
var probe = elementExpando[node];
3030
if (probe != null) return probe;
31-
node = node.parent;
31+
if (node is dom.ShadowRoot) {
32+
node = (node as dom.ShadowRoot).host;
33+
} else {
34+
node = node.parentNode;
35+
}
3236
}
3337
return null;
3438
}
@@ -40,6 +44,14 @@ _walkProbesInTree(dom.Node node, Function walker) {
4044
for (var child in node.childNodes) {
4145
_walkProbesInTree(child, walker);
4246
}
47+
if (node is dom.Element) {
48+
var shadowRoot = (node as dom.Element).shadowRoot;
49+
if (shadowRoot != null) {
50+
for (var child in shadowRoot.childNodes) {
51+
_walkProbesInTree(child, walker);
52+
}
53+
}
54+
}
4355
}
4456
}
4557

0 commit comments

Comments
 (0)