From: Rick Waldron Date: Fri, 5 Aug 2011 13:43:58 +0000 (-0400) Subject: Supports interoperable removal of hyphenated/camelCase properties. Fixes #9413 X-Git-Tag: 1.6.3rc1~22^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F455%2Fhead;p=jquery.git Supports interoperable removal of hyphenated/camelCase properties. Fixes #9413 --- diff --git a/src/data.js b/src/data.js index 1e82961fc..279471075 100644 --- a/src/data.js +++ b/src/data.js @@ -135,7 +135,12 @@ jQuery.extend({ return; } - var internalKey = jQuery.expando, isNode = elem.nodeType, + var thisCache, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, // See jQuery.data for more information cache = isNode ? jQuery.cache : elem, @@ -150,9 +155,16 @@ jQuery.extend({ } if ( name ) { - var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; + + thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; if ( thisCache ) { + + // Support interoperable removal of hyphenated or camelcased keys + if ( !thisCache[ name ] ) { + name = jQuery.camelCase( name ); + } + delete thisCache[ name ]; // If there is no data left in the cache, we want to continue