siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
46 lines (34 loc) • 1.39 kB
JavaScript
/*
Siesta 5.6.1
Copyright(c) 2009-2022 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license
*/
Role('Ariadne.ExtJSComponentQueryFinder.TreeWalker', {
methods : {
getParent : function (cmp) {
return cmp.getRefOwner && cmp.getRefOwner() || cmp.ownerCt || this.Ext.ComponentQuery
},
contains : function (parentCmp, childCmp) {
// if (parentCmp == this.Ext.ComponentQuery) return true
// if (childCmp == this.Ext.ComponentQuery) return false
//
// // "comp.contains()" may throw exception
// // https://www.sencha.com/forum/showthread.php?331619-6-2-CQ-crash&p=1164685#post1164685
// try {
// return parentCmp == childCmp || parentCmp.contains && parentCmp.contains(childCmp, true) || false
// } catch (e) {
// return false
// }
// the new, more robust to various glitches implementation of "contains"
var CQ = this.Ext.ComponentQuery
if (parentCmp == CQ) return true
if (childCmp == CQ) return false
while (childCmp && childCmp != CQ) {
if (childCmp == parentCmp) return true
childCmp = this.getParent(childCmp)
}
return false
}
}
});