[jQuery] Suggestion: Expressing variable names for jQuery
Frankly, I find the code quite readable. I'm not a big one for long var
names if they're only used in a scope of a handful of lines. $.attr() is
perfectly clear even though it uses single letter parms. Frankly, I'd find
it harder to read if the variable names were verbose.
$.attr = function(o,a,v){
if ( a && a.constructor == String ) {
var fix = {
'for': 'htmlFor',
'text': 'cssText',
'class': 'className',
'float': 'cssFloat'
};
a = (fix[a] && fix[a].replace && fix[a]) || a;
var r = new RegExp("-([a-z])","ig");
a = a.replace(r,function(z,b){return b.toUpperCase();});
if ( v != null ) {
o[a] = v;
if ( o.setAttribute ) o.setAttribute(a,v);
}
return o[a] || o.getAttribute(a) || '';
} else return '';
};