PDA

View Full Version : [FIXED][2.0,3.0]Ext.Element uses an arbitrary maxDepth value which is too small.



Animal
29 Jun 2009, 11:59 PM
When an Element is passed as the maxDepth (meaning "Stop following the parentNode axis when you reach this element"), it only attempts to go up 10 levels which may not be enough.

If you pass a "stop element", you mean it!

I suggest that the code be



Ext.override(Ext.Element, {
findParent : function(simpleSelector, maxDepth, returnEl){
var p = this.dom, b = document.body, depth = 0, dq = Ext.DomQuery, stopEl;
maxDepth = maxDepth || 50;
if(typeof maxDepth != "number"){
stopEl = Ext.getDom(maxDepth);
maxDepth = Number.MAX_VALUE;
}
while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
if(dq.is(p, simpleSelector)){
return returnEl ? Ext.get(p) : p;
}
depth++;
p = p.parentNode;
}
return null;
}
});

Animal
30 Jun 2009, 12:01 AM
Based on a problem with DataView when using a very complex XTemplate with deeply nested nodes: http://extjs.com/forum/showthread.php?t=72811

Condor
30 Jun 2009, 12:03 AM
I was going to post a comment to your previous bugreport (which was obviously nonsense), but this one I can fully agree with.

I wondered about the '10' limitation before, but I haven't hit the limit in my own code yet, so I didn't post a report about it.

Animal
30 Jun 2009, 12:33 AM
I was going to post a comment to your previous bugreport (which was obviously nonsense)

It certainly was. :">

It's early here, I haven't had my morning shower or fruit salad yet. I left the nonsense in the other thread.

evant
30 Jun 2009, 5:42 AM
Fixed in SVN.