\r
var id = elem[ expando ], cache = jQuery.cache, thisCache;\r
\r
- // Compute a unique ID for the element\r
- if(!id) id = elem[ expando ] = ++uuid;\r
-\r
// Handle the case where there's no name immediately\r
- if ( !name ) { return id; }\r
+ if ( !name && !id ) {\r
+ return null;\r
+ }\r
+\r
+ // Compute a unique ID for the element\r
+ if ( !id ) { \r
+ id = ++uuid;\r
+ }\r
\r
// Avoid generating a new cache unless none exists and we\r
// want to manipulate it.\r
- if( cache[ id ] )\r
+ if ( cache[ id ] ) {\r
thisCache = cache[ id ];\r
- else if( typeof data === "undefined" )\r
+ } else if ( typeof data === "undefined" ) {\r
thisCache = emptyObject;\r
- else\r
+ } else {\r
thisCache = cache[ id ] = {};\r
+ }\r
\r
// Prevent overriding the named cache with undefined values\r
- if ( data !== undefined ) thisCache[ name ] = data;\r
-\r
- if(name === true) return thisCache;\r
- else return thisCache[name];\r
+ if ( data !== undefined ) {\r
+ elem[ expando ] = id;\r
+ thisCache[ name ] = data;\r
+ }\r
+ \r
+ return name ? thisCache[ name ] : thisCache;\r
},\r
\r
removeData: function( elem, name ) {\r
delete thisCache[ name ];\r
\r
// If we've removed all the data, remove the element's cache\r
- if( jQuery.isEmptyObject(thisCache) )\r
+ if ( jQuery.isEmptyObject(thisCache) ) {\r
jQuery.removeData( elem );\r
+ }\r
}\r
\r
// Otherwise, we want to remove all of the element's data\r
// Clean up the element expando\r
try {\r
delete elem[ expando ];\r
- } catch(e){\r
+ } catch( e ) {\r
// IE has trouble directly removing the expando\r
// but it's ok with using removeAttribute\r
- if ( elem.removeAttribute )\r
+ if ( elem.removeAttribute ) {\r
elem.removeAttribute( expando );\r
+ }\r
}\r
\r
// Completely remove the data cache\r
delete cache[ id ];\r
}\r
},\r
+ \r
queue: function( elem, type, data ) {\r
if( !elem ) return;\r
\r
\r
jQuery.fn.extend({\r
data: function( key, value ){\r
- if(typeof key === "undefined" && this.length) return jQuery.data(this[0], true);\r
+ if ( typeof key === "undefined" && this.length ) {\r
+ return jQuery.data( this[0] );\r
+ }\r
\r
var parts = key.split(".");\r
parts[1] = parts[1] ? "." + parts[1] : "";\r
clearQueue: function(type){\r
return this.queue( type || "fx", [] );\r
}\r
-});
\ No newline at end of file
+});\r