PDA

View Full Version : YAHOO.ext.Element.select (in CompositeElement.js)



gcsolaroli
10 Nov 2006, 1:13 AM
Studying the YUI-ext code to try to understand how to use it, I stumble upon the YAHOO.ext.Element.select function.



YAHOO.ext.Element.select = function(selector, unique){
var els;
if(typeof selector == 'string'){
els = YAHOO.ext.Element.selectorFunction(selector);
}else if(els instanceof Array){
els = selector;
}else{
throw 'Invalid selector';
}
if(unique === true){
return new YAHOO.ext.CompositeElement(els);
}else{
return new YAHOO.ext.CompositeElementLite(els);
}
};


I think there is something wrong here, as the statemet



...
}else if(els instanceof Array){
...


is performed without ever inizializing the value of the 'els' variable.

If I understand the code right (but this is easily questionable), it should better read like this:


...
}else if(selector instanceof Array){
...



This should be relative to version 0.33-beta4 of YUI-ext.

jack.slocum
10 Nov 2006, 2:38 AM
Should be selector not els. I have corrected it. Thanks.