add back deepContains (got removed incorrectly in merge).

This commit is contained in:
Steven Orvell 2015-11-04 17:18:26 -08:00
parent 0233d6deaf
commit d53ab5736f

View File

@ -52,6 +52,28 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.dom.flush();
},
/**
* Check that the given node is a descendant of `this`,
* ignoring ShadowDOM boundaries
* @param {Node} node
* @return {Boolean} true if `node` is a descendant or equal to `this`
*/
deepContains: function(node) {
// fast path, use shallow `contains`.
if (this.node.contains(node)) {
return true;
}
var n = node;
// wrap document for SD polyfill
var wrappedDocument = wrap(document);
// walk from node to `this` or `document`
while (n && n !== wrappedDocument && n !== this.node) {
// use logical parentnode, or native ShadowRoot host
n = Polymer.dom(n).parentNode || n.host;
}
return n === this.node;
},
_lazyDistribute: function(host) {
// note: only try to distribute if the root is not clean; this ensures
// we don't distribute before initial distribution