diff options
Diffstat (limited to 'src/data.js')
-rw-r--r-- | src/data.js | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/data.js b/src/data.js index f69d9decd..353a0918c 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 the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + + // Test for null|undefined property data was found + if ( ret == null ) { + + // Try to find as-is property data + ret = thisCache[ name ]; + } + } else { + ret = thisCache; + } + + return ret; }, removeData: function( elem, name, pvt /* Internal Use Only */ ) { |