MCPcopy
hub / github.com/geekape/geek-navigation / access

Function access

js/jquery.js:3957–4014  ·  view source on GitHub ↗
( elems, fn, key, value, chainable, emptyGet, raw )

Source from the content-addressed store, hash-verified

3955// Multifunctional method to get and set values of a collection
3956// The value/s can optionally be executed if it's a function
3957var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3958 var i = 0,
3959 len = elems.length,
3960 bulk = key == null;
3961
3962 // Sets many values
3963 if ( jQuery.type( key ) === "object" ) {
3964 chainable = true;
3965 for ( i in key ) {
3966 access( elems, fn, i, key[ i ], true, emptyGet, raw );
3967 }
3968
3969 // Sets one value
3970 } else if ( value !== undefined ) {
3971 chainable = true;
3972
3973 if ( !jQuery.isFunction( value ) ) {
3974 raw = true;
3975 }
3976
3977 if ( bulk ) {
3978
3979 // Bulk operations run against the entire set
3980 if ( raw ) {
3981 fn.call( elems, value );
3982 fn = null;
3983
3984 // ...except when executing function values
3985 } else {
3986 bulk = fn;
3987 fn = function( elem, key, value ) {
3988 return bulk.call( jQuery( elem ), value );
3989 };
3990 }
3991 }
3992
3993 if ( fn ) {
3994 for ( ; i < len; i++ ) {
3995 fn(
3996 elems[ i ], key, raw ?
3997 value :
3998 value.call( elems[ i ], i, fn( elems[ i ], key ) )
3999 );
4000 }
4001 }
4002 }
4003
4004 if ( chainable ) {
4005 return elems;
4006 }
4007
4008 // Gets
4009 if ( bulk ) {
4010 return fn.call( elems );
4011 }
4012
4013 return len ? fn( elems[ 0 ], key ) : emptyGet;
4014};

Callers 1

jquery.jsFile · 0.85

Calls 1

jQueryFunction · 0.85

Tested by

no test coverage detected