git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make sure that jQuery works even when the individual modules are loaded separately...
[jquery.git]
/
src
/
data.js
diff --git
a/src/data.js
b/src/data.js
index
c524a45
..
5404c93
100644
(file)
--- a/
src/data.js
+++ b/
src/data.js
@@
-1,3
+1,5
@@
+(function( jQuery ) {
+
var windowData = {};
jQuery.extend({
var windowData = {};
jQuery.extend({
@@
-27,7
+29,8
@@
jQuery.extend({
elem;
var id = elem[ jQuery.expando ], cache = jQuery.cache, thisCache,
elem;
var id = elem[ jQuery.expando ], cache = jQuery.cache, thisCache,
- isNode = elem.nodeType;
+ isNode = elem.nodeType,
+ store;
if ( !id && typeof name === "string" && data === undefined ) {
return;
if ( !id && typeof name === "string" && data === undefined ) {
return;
@@
-49,8
+52,9
@@
jQuery.extend({
if ( isNode ) {
cache[ id ] = jQuery.extend(true, {}, name);
} else {
if ( isNode ) {
cache[ id ] = jQuery.extend(true, {}, name);
} else {
+ store = jQuery.extend(true, {}, name);
cache[ id ] = function() {
cache[ id ] = function() {
- return jQuery.extend(true, {}, name);
+ return store;
};
}
};
}
@@
-58,7
+62,7
@@
jQuery.extend({
if ( isNode ) {
cache[ id ] = {};
} else {
if ( isNode ) {
cache[ id ] = {};
} else {
- var store = {};
+ store = {};
cache[ id ] = function() {
return store;
};
cache[ id ] = function() {
return store;
};
@@
-66,7
+70,7
@@
jQuery.extend({
}
}
- thisCache = isNode? cache[ id ] : cache[ id ]();
+ thisCache = isNode ? cache[ id ] : cache[ id ]();
// Prevent overriding the named cache with undefined values
if ( data !== undefined ) {
// Prevent overriding the named cache with undefined values
if ( data !== undefined ) {
@@
-141,13
+145,18
@@
jQuery.fn.extend({
if ( data === undefined && this.length ) {
data = jQuery.data( this[0], key );
}
if ( data === undefined && this.length ) {
data = jQuery.data( this[0], key );
}
+
return data === undefined && parts[1] ?
this.data( parts[0] ) :
data;
return data === undefined && parts[1] ?
this.data( parts[0] ) :
data;
+
} else {
} else {
- return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ return this.each(function() {
+ var $this = jQuery( this ), args = [ parts[0], value ];
+
+ $this.triggerHandler( "setData" + parts[1] + "!", args );
jQuery.data( this, key, value );
jQuery.data( this, key, value );
- jQuery.event.trigger( "changeData" + parts[1] + "!", [parts[0], value], this );
+ $this.triggerHandler( "changeData" + parts[1] + "!", args );
});
}
},
});
}
},
@@
-158,3
+167,5
@@
jQuery.fn.extend({
});
}
});
});
}
});
+
+})( jQuery );