git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use the native Array indexOf method if it exists, for jQuery.inArray.
[jquery.git]
/
src
/
data.js
diff --git
a/src/data.js
b/src/data.js
index
ac069ce
..
03116e4
100644
(file)
--- a/
src/data.js
+++ b/
src/data.js
@@
-8,25
+8,24
@@
jQuery.extend({
windowData :
\r
elem;
\r
\r
windowData :
\r
elem;
\r
\r
- var id = elem[ expando ];
\r
+ var id = elem[ expando ], cache = jQuery.cache;
\r
\r
// Compute a unique ID for the element
\r
\r
// Compute a unique ID for the element
\r
- if ( !id )
\r
- id = elem[ expando ] = ++uuid;
\r
+ if(!id) id = elem[ expando ] = ++uuid;
\r
\r
// Only generate the data cache if we're
\r
// trying to access or manipulate it
\r
\r
// Only generate the data cache if we're
\r
// trying to access or manipulate it
\r
- if ( name && !jQuery.cache[ id ] )
\r
- jQuery.cache[ id ] = {};
\r
+ if ( name && !cache[ id ] )
\r
+ cache[ id ] = {};
\r
+
\r
+ var thisCache = cache[ id ];
\r
\r
// Prevent overriding the named cache with undefined values
\r
\r
// Prevent overriding the named cache with undefined values
\r
- if ( data !== undefined )
\r
- jQuery.cache[ id ][ name ] = data;
\r
+ if ( data !== undefined ) thisCache[ name ] = data;
\r
\r
\r
- // Return the named cache data, or the ID for the element
\r
- return name ?
\r
- jQuery.cache[ id ][ name ] :
\r
- id;
\r
+ if(name === true) return thisCache
\r
+ else if(name) return thisCache[name]
\r
+ else return id
\r
},
\r
\r
removeData: function( elem, name ) {
\r
},
\r
\r
removeData: function( elem, name ) {
\r
@@
-34,21
+33,16
@@
jQuery.extend({
windowData :
\r
elem;
\r
\r
windowData :
\r
elem;
\r
\r
- var id = elem[ expando ];
\r
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
\r
\r
// If we want to remove a specific section of the element's data
\r
if ( name ) {
\r
\r
// If we want to remove a specific section of the element's data
\r
if ( name ) {
\r
- if ( jQuery.cache[ id ] ) {
\r
+ if ( thisCache ) {
\r
// Remove the section of cache data
\r
// Remove the section of cache data
\r
- delete jQuery.cache[ id ][ name ];
\r
+ delete thisCache[ name ];
\r
\r
// If we've removed all the data, remove the element's cache
\r
\r
// If we've removed all the data, remove the element's cache
\r
- name = "";
\r
-
\r
- for ( name in jQuery.cache[ id ] )
\r
- break;
\r
-
\r
- if ( !name )
\r
+ if( jQuery.isEmptyObject(thisCache) )
\r
jQuery.removeData( elem );
\r
}
\r
\r
jQuery.removeData( elem );
\r
}
\r
\r
@@
-65,39
+59,48
@@
jQuery.extend({
}
\r
\r
// Completely remove the data cache
\r
}
\r
\r
// Completely remove the data cache
\r
- delete jQuery.cache[ id ];
\r
+ delete cache[ id ];
\r
}
\r
},
\r
queue: function( elem, type, data ) {
\r
}
\r
},
\r
queue: function( elem, type, data ) {
\r
- if ( elem ){
\r
+ if( !elem ) return;
\r
\r
\r
- type = (type || "fx") + "queue";
\r
+ type = (type || "fx") + "queue";
\r
+ var q = jQuery.data( elem, type );
\r
\r
\r
- var q = jQuery.data( elem, type );
\r
+ // Speed up dequeue by getting out quickly if this is just a lookup
\r
+ if( !data ) return q || [];
\r
\r
\r
- if ( !q || jQuery.isArray(data) )
\r
- q = jQuery.data( elem, type, jQuery.makeArray(data) );
\r
- else if( data )
\r
- q.push( data );
\r
+ if ( !q || jQuery.isArray(data) )
\r
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
\r
+ else
\r
+ q.push( data );
\r
\r
\r
- }
\r
return q;
\r
},
\r
\r
dequeue: function( elem, type ){
\r
return q;
\r
},
\r
\r
dequeue: function( elem, type ){
\r
- var queue = jQuery.queue( elem, type ),
\r
- fn = queue.shift();
\r
+ type = type || "fx";
\r
+
\r
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
\r
\r
\r
- if( !type || type === "fx" )
\r
- fn = queue[0];
\r
+ // If the fx queue is dequeued, always remove the progress sentinel
\r
+ if( fn === "inprogress" ) fn = queue.shift();
\r
\r
\r
- if( fn !== undefined )
\r
- fn.call(elem);
\r
+ if( fn ) {
\r
+ // Add a progress sentinel to prevent the fx queue from being
\r
+ // automatically dequeued
\r
+ if( type == "fx" ) queue.unshift("inprogress");
\r
+
\r
+ fn.call(elem, function() { jQuery.dequeue(elem, type); });
\r
+ }
\r
}
\r
});
\r
\r
jQuery.fn.extend({
\r
data: function( key, value ){
\r
}
\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
+
\r
var parts = key.split(".");
\r
parts[1] = parts[1] ? "." + parts[1] : "";
\r
\r
var parts = key.split(".");
\r
parts[1] = parts[1] ? "." + parts[1] : "";
\r
\r
@@
-130,16
+133,19
@@
jQuery.fn.extend({
if ( data === undefined )
\r
return jQuery.queue( this[0], type );
\r
\r
if ( data === undefined )
\r
return jQuery.queue( this[0], type );
\r
\r
- return this.each(function(){
\r
+ return this.each(function(i, elem){
\r
var queue = jQuery.queue( this, type, data );
\r
\r
var queue = jQuery.queue( this, type, data );
\r
\r
- if( type == "fx" && queue.length == 1 )
\r
- queue[0].call(this);
\r
+ if( type == "fx" && queue[0] !== "inprogress" )
\r
+ jQuery.dequeue( this, type )
\r
});
\r
},
\r
dequeue: function(type){
\r
return this.each(function(){
\r
jQuery.dequeue( this, type );
\r
});
\r
});
\r
},
\r
dequeue: function(type){
\r
return this.each(function(){
\r
jQuery.dequeue( this, type );
\r
});
\r
+ },
\r
+ clearQueue: function(type){
\r
+ return this.queue( type || "fx", [] );
\r
}
\r
});
\ No newline at end of file
}
\r
});
\ No newline at end of file