aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-08-04 14:55:21 -0700
committerDave Methvin <dave.methvin@gmail.com>2011-08-04 14:55:21 -0700
commit59936dc04d4dd2731874fecd6237383a0e41ddd5 (patch)
tree83338a8a0ed87bf6201a417d4326e3c4ebf664e5 /src
parent2e298d92dbba3f9984a7765026e4c3341f709366 (diff)
parent8fed1e7b5e1248c79b06f5f34d286e27c79b3e57 (diff)
downloadjquery-59936dc04d4dd2731874fecd6237383a0e41ddd5.tar.gz
jquery-59936dc04d4dd2731874fecd6237383a0e41ddd5.zip
Merge pull request #432 from rwldrn/9794
Correct non-null|undefined evaluation of data property values. Fixes #9779
Diffstat (limited to 'src')
-rw-r--r--src/data.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/data.js b/src/data.js
index f69d9decd..1e82961fc 100644
--- a/src/data.js
+++ b/src/data.js
@@ -33,7 +33,9 @@ jQuery.extend({
return;
}
- var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
+ var thisCache, ret,
+ internalKey = jQuery.expando,
+ getByName = typeof name === "string",
// We have to handle DOM nodes and JS objects differently because IE6-7
// can't GC object references properly across the DOM-JS boundary
@@ -108,10 +110,24 @@ jQuery.extend({
return thisCache[ internalKey ] && thisCache[ internalKey ].events;
}
- return getByName ?
- // Check for both converted-to-camel and non-converted data property names
- thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] :
- thisCache;
+ // Check for both converted-to-camel and non-converted data property names
+ // If a data property was specified
+ if ( getByName ) {
+
+ // First Try to find as-is property data
+ ret = thisCache[ name ];
+
+ // Test for null|undefined property data
+ if ( ret == null ) {
+
+ // Try to find the camelCased property
+ ret = thisCache[ jQuery.camelCase( name ) ];
+ }
+ } else {
+ ret = thisCache;
+ }
+
+ return ret;
},
removeData: function( elem, name, pvt /* Internal Use Only */ ) {