PDA

View Full Version : [FIXED-458][3.1] CompositeElementLite.each() breaking does not work



Alexey Sinko
19 Jan 2010, 6:54 PM
Ext version tested:

Ext 3.1.0
Ext 3.1.1-beta_5899-129
and also Ext Core 3.1.0


Description:

Returning false from the function not stop the iteration.


Steps to reproduce the problem:

Create two or more div elements
Run script

Ext.select('div').each(function(el){
alert('test message');
return false;
});



The result that was expected:

Many alert with text 'test message'


The result that occurs instead:

Only one alert with text 'test message'


Reason:


ext-3.0.3/src/core/core/CompositeElementLite.js

each : function(fn, scope){
var me = this,
el = me.el;

Ext.each(me.elements, function(e,i) {
el.dom = e;
return fn.call(scope || el, el, me, i);
});
return me;
},

ext-3.1.0/src/core/core/CompositeElementLite.js

each : function(fn, scope){
var me = this,
els = me.elements,
len = els.length,
i, e;

for(i = 0; i<len; i++) {
e = els[i];
if(e){
e = this.getElement(e);
if(fn.call(scope || e, e, me, i)){
break;
}
}
}
return me;
},



Possible fix:

change

if(fn.call(scope || e, e, me, i)){
to

if(fn.call(scope || e, e, me, i) === false){

evant
19 Jan 2010, 7:22 PM
Agreed, thanks for the report.

evant
19 Jan 2010, 7:25 PM
Fixed in SVN.