MCPcopy
hub / github.com/jquery/jquery / access

Function access

src/core/access.js:6–63  ·  view source on GitHub ↗
( elems, fn, key, value, chainable, emptyGet, raw )

Source from the content-addressed store, hash-verified

4// Multifunctional method to get and set values of a collection
5// The value/s can optionally be executed if it's a function
6export function access( elems, fn, key, value, chainable, emptyGet, raw ) {
7 var i = 0,
8 len = elems.length,
9 bulk = key == null;
10
11 // Sets many values
12 if ( toType( key ) === "object" ) {
13 chainable = true;
14 for ( i in key ) {
15 access( elems, fn, i, key[ i ], true, emptyGet, raw );
16 }
17
18 // Sets one value
19 } else if ( value !== undefined ) {
20 chainable = true;
21
22 if ( typeof value !== "function" ) {
23 raw = true;
24 }
25
26 if ( bulk ) {
27
28 // Bulk operations run against the entire set
29 if ( raw ) {
30 fn.call( elems, value );
31 fn = null;
32
33 // ...except when executing function values
34 } else {
35 bulk = fn;
36 fn = function( elem, _key, value ) {
37 return bulk.call( jQuery( elem ), value );
38 };
39 }
40 }
41
42 if ( fn ) {
43 for ( ; i < len; i++ ) {
44 fn(
45 elems[ i ], key, raw ?
46 value :
47 value.call( elems[ i ], i, fn( elems[ i ], key ) )
48 );
49 }
50 }
51 }
52
53 if ( chainable ) {
54 return elems;
55 }
56
57 // Gets
58 if ( bulk ) {
59 return fn.call( elems );
60 }
61
62 return len ? fn( elems[ 0 ], key ) : emptyGet;
63}

Callers 7

dimensions.jsFile · 0.90
offset.jsFile · 0.90
css.jsFile · 0.90
data.jsFile · 0.90
manipulation.jsFile · 0.90
prop.jsFile · 0.90
attr.jsFile · 0.90

Calls 3

toTypeFunction · 0.90
jQueryFunction · 0.90
fnFunction · 0.50

Tested by

no test coverage detected