diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-11-13 16:02:32 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-11-13 20:04:07 +0300 |
commit | c69673fe41ee17f46545e87a31ff96cea6c68a17 (patch) | |
tree | b6944633d44b4adf81c1bf33c428334364a6a012 /src | |
parent | 2d9d1f006ac98b3dd1f23de1b721f54eb77346db (diff) | |
download | jquery-c69673fe41ee17f46545e87a31ff96cea6c68a17.tar.gz jquery-c69673fe41ee17f46545e87a31ff96cea6c68a17.zip |
Release: remove revert artefacts
Diffstat (limited to 'src')
-rw-r--r-- | src/data.js | 9 | ||||
-rw-r--r-- | src/data/Data.js | 17 | ||||
-rw-r--r-- | src/deferred.js | 29 | ||||
-rw-r--r-- | src/offset.js | 4 | ||||
-rw-r--r-- | src/wrap.js | 4 |
5 files changed, 39 insertions, 24 deletions
diff --git a/src/data.js b/src/data.js index 17e9c64f1..f7734e7f3 100644 --- a/src/data.js +++ b/src/data.js @@ -120,6 +120,7 @@ jQuery.fn.extend( { // will result in `undefined` for elem = this[ 0 ] which will // throw an exception if an attempt to read a data cache is made. if ( elem && value === undefined ) { + // Attempt to get data from the cache // with the key as-is data = dataUser.get( elem, key ); @@ -128,6 +129,7 @@ jQuery.fn.extend( { } camelKey = jQuery.camelCase( key ); + // Attempt to get data from the cache // with the key camelized data = dataUser.get( elem, camelKey ); @@ -148,7 +150,8 @@ jQuery.fn.extend( { // Set the data... camelKey = jQuery.camelCase( key ); - this.each(function() { + this.each( function() { + // First, attempt to store a copy or reference of any // data that might've been store with a camelCased key. var data = dataUser.get( this, camelKey ); @@ -161,10 +164,10 @@ jQuery.fn.extend( { // *... In the case of properties that might _actually_ // have dashes, we need to also store a copy of that // unchanged property. - if ( key.indexOf("-") > -1 && data !== undefined ) { + if ( key.indexOf( "-" ) > -1 && data !== undefined ) { dataUser.set( this, key, value ); } - }); + } ); }, null, value, arguments.length > 1, null, true ); }, diff --git a/src/data/Data.js b/src/data/Data.js index b33f13497..0e29c1fc6 100644 --- a/src/data/Data.js +++ b/src/data/Data.js @@ -28,11 +28,12 @@ Data.prototype = { value: value, writable: true, configurable: true - }); + } ); } return owner[ this.expando ]; }, - cache: function( owner, initial ) { + cache: function( owner ) { + // We can accept data for non-element nodes in modern browsers, // but we should not, see #8335. // Always return an empty object. @@ -81,6 +82,7 @@ Data.prototype = { // Handle: [ owner, { properties } ] args } else { + // Copy the properties one-by-one to the cache object for ( prop in data ) { cache[ prop ] = data[ prop ]; @@ -91,10 +93,11 @@ Data.prototype = { get: function( owner, key ) { return key === undefined ? this.cache( owner ) : - owner[ this.expando ] && owner[ this.expando ][ key ] + owner[ this.expando ] && owner[ this.expando ][ key ]; }, access: function( owner, key, value ) { var stored; + // In cases where either: // // 1. No key was specified @@ -107,12 +110,12 @@ Data.prototype = { // 2. The data stored at the key // if ( key === undefined || - ((key && typeof key === "string") && value === undefined) ) { + ( ( key && typeof key === "string" ) && value === undefined ) ) { stored = this.get( owner, key ); return stored !== undefined ? - stored : this.get( owner, jQuery.camelCase(key) ); + stored : this.get( owner, jQuery.camelCase( key ) ); } // When the key is not a string, or both a key and value @@ -139,8 +142,10 @@ Data.prototype = { this.register( owner ); } else { + // Support array or space separated string of keys if ( jQuery.isArray( key ) ) { + // If "name" is an array of keys... // When data is initially created, via ("key", "val") signature, // keys will be converted to camelCase. @@ -150,10 +155,12 @@ Data.prototype = { name = key.concat( key.map( jQuery.camelCase ) ); } else { camel = jQuery.camelCase( key ); + // Try the string as a key before any manipulation if ( key in cache ) { name = [ key, camel ]; } else { + // If a key with the spaces exists, use it. // Otherwise, create an array by matching non-whitespace name = camel; diff --git a/src/deferred.js b/src/deferred.js index b56a40104..d2cd6080f 100644 --- a/src/deferred.js +++ b/src/deferred.js @@ -4,14 +4,15 @@ define( [ "./callbacks" ], function( jQuery, slice ) { -jQuery.extend({ +jQuery.extend( { Deferred: function( func ) { var tuples = [ + // action, add listener, listener list, final state - [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], - [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], - [ "notify", "progress", jQuery.Callbacks("memory") ] + [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ], + [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ], + [ "notify", "progress", jQuery.Callbacks( "memory" ) ] ], state = "pending", promise = { @@ -24,11 +25,12 @@ jQuery.extend({ }, then: function( /* fnDone, fnFail, fnProgress */ ) { var fns = arguments; - return jQuery.Deferred(function( newDefer ) { + return jQuery.Deferred( function( newDefer ) { jQuery.each( tuples, function( i, tuple ) { var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer - deferred[ tuple[1] ](function() { + deferred[ tuple[ 1 ] ]( function() { var returned = fn && fn.apply( this, arguments ); if ( returned && jQuery.isFunction( returned.promise ) ) { returned.promise() @@ -46,6 +48,7 @@ jQuery.extend({ fns = null; } ).promise(); }, + // Get a promise for this deferred // If obj is provided, the promise aspect is added to the object promise: function( obj ) { @@ -63,11 +66,12 @@ jQuery.extend({ stateString = tuple[ 3 ]; // promise[ done | fail | progress ] = list.add - promise[ tuple[1] ] = list.add; + promise[ tuple[ 1 ] ] = list.add; // Handle state if ( stateString ) { - list.add(function() { + list.add( function() { + // state = [ resolved | rejected ] state = stateString; @@ -76,12 +80,13 @@ jQuery.extend({ } // deferred[ resolve | reject | notify ] - deferred[ tuple[0] ] = function() { - deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); + deferred[ tuple[ 0 ] ] = function() { + deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); return this; }; - deferred[ tuple[0] + "With" ] = list.fireWith; - }); + deferred[ tuple[ 0 ] + "With" ] = list.fireWith; + } ); + // Make the deferred a promise promise.promise( deferred ); diff --git a/src/offset.js b/src/offset.js index acc41997a..4352a9995 100644 --- a/src/offset.js +++ b/src/offset.js @@ -77,9 +77,9 @@ jQuery.fn.extend( { if ( arguments.length ) { return options === undefined ? this : - this.each(function( i ) { + this.each( function( i ) { jQuery.offset.setOffset( this, options, i ); - }); + } ); } var docElem, win, diff --git a/src/wrap.js b/src/wrap.js index c85cd304e..32d1d331f 100644 --- a/src/wrap.js +++ b/src/wrap.js @@ -64,11 +64,11 @@ jQuery.fn.extend( { }, unwrap: function() { - return this.parent().each(function() { + return this.parent().each( function() { if ( !jQuery.nodeName( this, "body" ) ) { jQuery( this ).replaceWith( this.childNodes ); } - }).end(); + } ).end(); } } ); |