diff --git a/src/lib/dom-api-shadow.html b/src/lib/dom-api-shadow.html
index daf15df8..e442b761 100644
--- a/src/lib/dom-api-shadow.html
+++ b/src/lib/dom-api-shadow.html
@@ -60,8 +60,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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
diff --git a/src/lib/dom-api-shady.html b/src/lib/dom-api-shady.html
index ccb93354..e1f62ffe 100644
--- a/src/lib/dom-api-shady.html
+++ b/src/lib/dom-api-shady.html
@@ -446,10 +446,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// 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.
diff --git a/test/unit/polymer-dom-elements.html b/test/unit/polymer-dom-elements.html
index a4c39fd7..64ac6b59 100644
--- a/test/unit/polymer-dom-elements.html
+++ b/test/unit/polymer-dom-elements.html
@@ -359,25 +359,13 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -599,3 +509,93 @@
});
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/unit/polymer-dom-native-shadow.html b/test/unit/polymer-dom-native-shadow.html
index d7b9d116..49b23aaf 100644
--- a/test/unit/polymer-dom-native-shadow.html
+++ b/test/unit/polymer-dom-native-shadow.html
@@ -56,6 +56,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
+
+
+
+