mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
add back deepContains (got removed incorrectly in merge).
This commit is contained in:
parent
0233d6deaf
commit
d53ab5736f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user