MCPcopy
hub / github.com/babysor/MockingBird / access

Function access

web/static/js/jquery.js:4147–4204  ·  view source on GitHub ↗
( elems, fn, key, value, chainable, emptyGet, raw )

Source from the content-addressed store, hash-verified

4145// Multifunctional method to get and set values of a collection
4146// The value/s can optionally be executed if it's a function
4147var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
4148 var i = 0,
4149 len = elems.length,
4150 bulk = key == null;
4151
4152 // Sets many values
4153 if ( toType( key ) === "object" ) {
4154 chainable = true;
4155 for ( i in key ) {
4156 access( elems, fn, i, key[ i ], true, emptyGet, raw );
4157 }
4158
4159 // Sets one value
4160 } else if ( value !== undefined ) {
4161 chainable = true;
4162
4163 if ( !isFunction( value ) ) {
4164 raw = true;
4165 }
4166
4167 if ( bulk ) {
4168
4169 // Bulk operations run against the entire set
4170 if ( raw ) {
4171 fn.call( elems, value );
4172 fn = null;
4173
4174 // ...except when executing function values
4175 } else {
4176 bulk = fn;
4177 fn = function( elem, _key, value ) {
4178 return bulk.call( jQuery( elem ), value );
4179 };
4180 }
4181 }
4182
4183 if ( fn ) {
4184 for ( ; i < len; i++ ) {
4185 fn(
4186 elems[ i ], key, raw ?
4187 value :
4188 value.call( elems[ i ], i, fn( elems[ i ], key ) )
4189 );
4190 }
4191 }
4192 }
4193
4194 if ( chainable ) {
4195 return elems;
4196 }
4197
4198 // Gets
4199 if ( bulk ) {
4200 return fn.call( elems );
4201 }
4202
4203 return len ? fn( elems[ 0 ], key ) : emptyGet;
4204};

Callers 1

jquery.jsFile · 0.85

Calls 4

toTypeFunction · 0.85
isFunctionFunction · 0.85
jQueryFunction · 0.85
fnFunction · 0.85

Tested by

no test coverage detected