summaryrefslogtreecommitdiff
path: root/bower_components/jquery/src/core/access.js
diff options
context:
space:
mode:
authorThomas Park <thomas@thomaspark.me>2014-11-01 21:05:20 -0400
committerThomas Park <thomas@thomaspark.me>2014-11-01 21:05:20 -0400
commit918b2a49ca6ac074bac47f6685cf3a687a4c6212 (patch)
tree5d11a2820c6e0726a6ee071724557d12a90c6709 /bower_components/jquery/src/core/access.js
parent5c12c8a99c04fbff7d13e97679121a5de13e01d6 (diff)
3.2.0 -> 3.3.0
Diffstat (limited to 'bower_components/jquery/src/core/access.js')
-rw-r--r--bower_components/jquery/src/core/access.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/bower_components/jquery/src/core/access.js b/bower_components/jquery/src/core/access.js
new file mode 100644
index 00000000..b6110c8f
--- /dev/null
+++ b/bower_components/jquery/src/core/access.js
@@ -0,0 +1,60 @@
+define([
+ "../core"
+], function( jQuery ) {
+
+// Multifunctional method to get and set values of a collection
+// The value/s can optionally be executed if it's a function
+var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
+ var i = 0,
+ len = elems.length,
+ bulk = key == null;
+
+ // Sets many values
+ if ( jQuery.type( key ) === "object" ) {
+ chainable = true;
+ for ( i in key ) {
+ jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
+ }
+
+ // Sets one value
+ } else if ( value !== undefined ) {
+ chainable = true;
+
+ if ( !jQuery.isFunction( value ) ) {
+ raw = true;
+ }
+
+ if ( bulk ) {
+ // Bulk operations run against the entire set
+ if ( raw ) {
+ fn.call( elems, value );
+ fn = null;
+
+ // ...except when executing function values
+ } else {
+ bulk = fn;
+ fn = function( elem, key, value ) {
+ return bulk.call( jQuery( elem ), value );
+ };
+ }
+ }
+
+ if ( fn ) {
+ for ( ; i < len; i++ ) {
+ fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
+ }
+ }
+ }
+
+ return chainable ?
+ elems :
+
+ // Gets
+ bulk ?
+ fn.call( elems ) :
+ len ? fn( elems[0], key ) : emptyGet;
+};
+
+return access;
+
+});