PDA

View Full Version : [FIXED-690] _tryPreloadAttach used by Elem.update doesn't work!



Arek (G)
5 Mar 2010, 4:29 AM
Ext version tested:


Ext 3.1.1



Adapter used:


ext


Very funny bug:) This function never call v.fn.call for each elements in onAvailStack array. So, method update with loadScripts = true can't work when it used for many elems in short period of time.



function _tryPreloadAttach(){
...
for (i = 0, len = onAvailStack.length; i < len; i++) {
v = onAvailStack[i];
if(v && (element = doc.getElementById(v.id))){
if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
element = v.override ? (v.override === true ? v.obj : v.override) : element;
v.fn.call(element, v.obj);
onAvailStack.remove(v);
} else {
notAvail.push(v);
}
}
}
...

Jamie Avins
5 Mar 2010, 10:04 AM
Do you have a test case for where this can be an issue?

hendricd
5 Mar 2010, 10:17 AM
Indeed,

Element.update (3.1.1 branch and higher) is missing the required:


var id = Ext.id(),
dom = this.dom;

html += '<span id="' + id + '"></span>';

Ext.lib.Event.onAvailable(id, function(){

Arek (G)
8 Mar 2010, 1:56 AM
Do you have a test case for where this can be an issue?


Yep. Try modify several elements:


for (i = 0; i < myResponse.elems.length; i++)
{
sId = myResponse.elems[i].id;
sContext = myResponse.elems[i].context;

var el = Ext.get(sId);
if( el )
el.update( sContext, true );
}


You can't modify all elems. Because, this loop has bug:


for (i = 0, len = onAvailStack.length; i < len; i++) {
v = onAvailStack[i];
...
v.fn.call(element, v.obj); onAvailStack.remove(v);
...
}

If you change code for something like that:


for (i = 0; i < onAvailStack.length; i++) {
v = onAvailStack[i];
if(v && (element = doc.getElementById(v.id))){
if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
element = v.override ? (v.override === true ? v.obj : v.override) : element;
v.fn.call(element, v.obj);
onAvailStack.remove(v);
i--;
} else {
notAvail.push(v);
}
}
}

this start work:)

evant
30 Mar 2010, 11:31 PM
Nice catch. Fixed in SVN.