Skip to content

Commit

Permalink
Use local references to wrapper functions; add test element tree to n…
Browse files Browse the repository at this point in the history
…ative shadow tests; reorder test elements.
  • Loading branch information
bicknellr committed Jan 8, 2016
1 parent e848af8 commit 47ee2ca
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 73 deletions.
5 changes: 4 additions & 1 deletion src/lib/dom-api-shadow.html
Expand Up @@ -60,8 +60,11 @@

activeElement: {
get: function() {
var node = Polymer.DomApi.wrap(this.node);
var node = DomApi.wrap(this.node);
var activeElement = node.activeElement;
// Prevents `activeElement` from returning elements outside of the
// ShadowRoot, even if they would become descendants of the ShadowRoot
// in the composed tree. See w3c/webcomponents#358.
return node.contains(activeElement) ? activeElement : null;
},
configurable: true
Expand Down
4 changes: 2 additions & 2 deletions src/lib/dom-api-shady.html
Expand Up @@ -446,10 +446,10 @@
// This node is either the document or a shady root of which the active
// element is a (composed) descendant of its host; iterate upwards to
// find the active element's most shallow host within it.
var activeRoot = Polymer.dom(active).getOwnerRoot();
var activeRoot = dom(active).getOwnerRoot();
while (activeRoot && activeRoot !== this.node) {
active = activeRoot.host;
activeRoot = Polymer.dom(active).getOwnerRoot();
activeRoot = dom(active).getOwnerRoot();
}
if (this.node === document) {
// This node is the document, so activeRoot should be null.
Expand Down
140 changes: 70 additions & 70 deletions test/unit/polymer-dom-elements.html
Expand Up @@ -359,36 +359,67 @@
</dom-module>


<dom-module id="x-shadow-host-root">
<dom-module id="x-shadow-host-root-0-0">
<template>
<content></content>
</template>
<script>
Polymer({
is: 'x-shadow-host-root-0-0',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-0-0-light-0">
<script>
Polymer({
is: 'x-shadow-host-root-0-0-light-0',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-0-0-light">
<template>
<div>
<div>
<x-shadow-host-root-0>
<x-shadow-host-root-0-light></x-shadow-host-root-0-light>
</x-shadow-host-root-0>
<x-shadow-host-root-0-0-light-0></x-shadow-host-root-0-0-light-0>
</div>
</div>
<div>
<x-shadow-host-root-1>
<x-shadow-host-root-1-light></x-shadow-host-root-1-light>
</x-shadow-host-root-1>
</div>
</template>
<script>
Polymer({
is: 'x-shadow-host-root',
is: 'x-shadow-host-root-0-0-light',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-light">
<dom-module id="x-shadow-host-root-0-1">
<template>
<content></content>
</template>
<script>
Polymer({
is: 'x-shadow-host-root-light',
is: 'x-shadow-host-root-0-1',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-0-1-light">
<script>
Polymer({
is: 'x-shadow-host-root-0-1-light',
hostAttributes: {
tabindex: '-1'
}
Expand Down Expand Up @@ -429,67 +460,49 @@
</script>
</dom-module>

<dom-module id="x-shadow-host-root-0-0">
<dom-module id="x-shadow-host-root-1-0">
<template>
<content></content>
</template>
<script>
Polymer({
is: 'x-shadow-host-root-0-0',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-0-0-light">
<template>
<div>
<div>
<x-shadow-host-root-0-0-light-0></x-shadow-host-root-0-0-light-0>
</div>
</div>
</template>
<script>
Polymer({
is: 'x-shadow-host-root-0-0-light',
is: 'x-shadow-host-root-1-0',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-0-0-light-0">
<dom-module id="x-shadow-host-root-1-0-light">
<script>
Polymer({
is: 'x-shadow-host-root-0-0-light-0',
is: 'x-shadow-host-root-1-0-light',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-0-1">
<dom-module id="x-shadow-host-root-1-1">
<template>
<content></content>
</template>
<script>
Polymer({
is: 'x-shadow-host-root-0-1',
is: 'x-shadow-host-root-1-1',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-0-1-light">
<dom-module id="x-shadow-host-root-1-1-light">
<script>
Polymer({
is: 'x-shadow-host-root-0-1-light',
is: 'x-shadow-host-root-1-1-light',
hostAttributes: {
tabindex: '-1'
}
Expand Down Expand Up @@ -525,20 +538,6 @@
</script>
</dom-module>

<dom-module id="x-shadow-host-root-1-light">
<template>
<x-shadow-host-root-1-light-0></x-shadow-host-root-1-light-0>
</template>
<script>
Polymer({
is: 'x-shadow-host-root-1-light',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-1-light-0">
<script>
Polymer({
Expand All @@ -550,49 +549,50 @@
</script>
</dom-module>

<dom-module id="x-shadow-host-root-1-0">
<dom-module id="x-shadow-host-root-1-light">
<template>
<content></content>
<x-shadow-host-root-1-light-0></x-shadow-host-root-1-light-0>
</template>
<script>
Polymer({
is: 'x-shadow-host-root-1-0',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-1-0-light">
<script>
Polymer({
is: 'x-shadow-host-root-1-0-light',
is: 'x-shadow-host-root-1-light',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-1-1">
<dom-module id="x-shadow-host-root">
<template>
<content></content>
<div>
<div>
<x-shadow-host-root-0>
<x-shadow-host-root-0-light></x-shadow-host-root-0-light>
</x-shadow-host-root-0>
</div>
</div>
<div>
<x-shadow-host-root-1>
<x-shadow-host-root-1-light></x-shadow-host-root-1-light>
</x-shadow-host-root-1>
</div>
</template>
<script>
Polymer({
is: 'x-shadow-host-root-1-1',
is: 'x-shadow-host-root',
hostAttributes: {
tabindex: '-1'
}
});
</script>
</dom-module>

<dom-module id="x-shadow-host-root-1-1-light">
<dom-module id="x-shadow-host-root-light">
<script>
Polymer({
is: 'x-shadow-host-root-1-1-light',
is: 'x-shadow-host-root-light',
hostAttributes: {
tabindex: '-1'
}
Expand Down
4 changes: 4 additions & 0 deletions test/unit/polymer-dom-native-shadow.html
Expand Up @@ -56,6 +56,10 @@

<x-wrapped></x-wrapped>

<x-shadow-host-root>
<x-shadow-host-root-light></x-shadow-host-root-light>
</x-shadow-host-root>

<script src="polymer-dom.js"></script>

</body>
Expand Down

0 comments on commit 47ee2ca

Please sign in to comment.