diff --git a/src/standard/utils.html b/src/standard/utils.html index d0cdab8982..cde1049772 100644 --- a/src/standard/utils.html +++ b/src/standard/utils.html @@ -150,7 +150,7 @@ * payload. * @param {Object=} options Object specifying options. These may include: * `bubbles` (boolean, defaults to `true`), - * `cancelable` (boolean, defaults to false), and + * `cancelable` (boolean, defaults to false), and * `node` on which to fire the event (HTMLElement, defaults to `this`). * @return {CustomEvent} The new event that was fired. */ @@ -199,11 +199,11 @@ /** * Removes an item from an array, if it exists. - * - * If the array is specified by path, a change notification is + * + * If the array is specified by path, a change notification is * generated, so that observers, data bindings and computed - * properties watching that path can update. - * + * properties watching that path can update. + * * If the array is passed directly, **no change * notification is generated**. * @@ -306,6 +306,29 @@ } } return elt; + }, + + /** + * Checks whether an element is in this element's light DOM tree. + * + * @method isLightDescendant + * @param {HTMLElement=} node The element to be checked. + * @return {Boolean} true if node is in this element's light DOM tree. + */ + isLightDescendant: function(node) { + return this.contains(node) && + Polymer.dom(this).getOwnerRoot() === Polymer.dom(node).getOwnerRoot(); + }, + + /** + * Checks whether an element is in this element's local DOM tree. + * + * @method isLocalDescendant + * @param {HTMLElement=} node The element to be checked. + * @return {Boolean} true if node is in this element's local DOM tree. + */ + isLocalDescendant: function(node) { + return this.root === Polymer.dom(node).getOwnerRoot(); } }); diff --git a/test/unit/utils-content.html b/test/unit/utils-content.html index 18ea1ab0db..bbc0492e96 100644 --- a/test/unit/utils-content.html +++ b/test/unit/utils-content.html @@ -26,7 +26,7 @@
- +
@@ -37,41 +37,50 @@
+ + + + + + + + + - + diff --git a/test/unit/utils-elements.html b/test/unit/utils-elements.html index 4729f91ba8..bb2503fd2e 100644 --- a/test/unit/utils-elements.html +++ b/test/unit/utils-elements.html @@ -37,4 +37,23 @@ Polymer({ is: 'x-content-multi' }); - \ No newline at end of file + + + + + + + + + diff --git a/test/unit/utils.html b/test/unit/utils.html index 7a630e6970..4415ce90b3 100644 --- a/test/unit/utils.html +++ b/test/unit/utils.html @@ -18,7 +18,7 @@