From 47ee2ca912ae3799e28774f2c833f6c35b29f3f8 Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Fri, 8 Jan 2016 14:11:25 -0800 Subject: [PATCH] Use local references to wrapper functions; add test element tree to native shadow tests; reorder test elements. --- src/lib/dom-api-shadow.html | 5 +- src/lib/dom-api-shady.html | 4 +- test/unit/polymer-dom-elements.html | 140 +++++++++++------------ test/unit/polymer-dom-native-shadow.html | 4 + 4 files changed, 80 insertions(+), 73 deletions(-) diff --git a/src/lib/dom-api-shadow.html b/src/lib/dom-api-shadow.html index daf15df8d9..e442b76112 100644 --- a/src/lib/dom-api-shadow.html +++ b/src/lib/dom-api-shadow.html @@ -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 diff --git a/src/lib/dom-api-shady.html b/src/lib/dom-api-shady.html index ccb9335429..e1f62ffe41 100644 --- a/src/lib/dom-api-shady.html +++ b/src/lib/dom-api-shady.html @@ -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. diff --git a/test/unit/polymer-dom-elements.html b/test/unit/polymer-dom-elements.html index a4c39fd7a1..64ac6b5972 100644 --- a/test/unit/polymer-dom-elements.html +++ b/test/unit/polymer-dom-elements.html @@ -359,25 +359,42 @@ - + + + + + + + + + + - + + + + + + - + - - - - - - + - + - + - - - - - - + - - - - - + - +