Made some minor formatting changes to the access function.

This commit is contained in:
John Resig 2009-12-10 09:07:19 -08:00
parent 80913618b0
commit ede2f2c4f7

View file

@ -657,7 +657,7 @@ function evalScript( i, elem ) {
// Mutifunctional method to get and set values to a collection // Mutifunctional method to get and set values to a collection
// The value/s can be optionally by executed if its a function // The value/s can be optionally by executed if its a function
function access( elems, key, value, exec, fn ) { function access( elems, key, value, exec, fn ) {
var l = elems.length; var length = elems.length;
// Setting many attributes // Setting many attributes
if ( typeof key === "object" ) { if ( typeof key === "object" ) {
@ -672,16 +672,15 @@ function access( elems, key, value, exec, fn ) {
// Optionally, function values get executed if exec is true // Optionally, function values get executed if exec is true
exec = exec && jQuery.isFunction(value); exec = exec && jQuery.isFunction(value);
for (var i = 0; i < l; i++) { for ( var i = 0; i < length; i++ ) {
var elem = elems[i], fn( elems[i], key, exec ? value.call( elems[i], i ) : value );
val = exec ? value.call(elem, i) : value;
fn(elem, key, val);
} }
return elems; return elems;
} }
// Getting an attribute // Getting an attribute
return l ? fn(elems[0], key) : null; return length ? fn( elems[0], key ) : null;
} }
function now() { function now() {