Skip to content

Commit 2ce5e95

Browse files
committed
Supports interoperable removal of hyphenated/camelCase properties. Fixes #9413
1 parent 7daf44b commit 2ce5e95

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/data.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,12 @@ jQuery.extend({
135135
return;
136136
}
137137

138-
var internalKey = jQuery.expando, isNode = elem.nodeType,
138+
var thisCache,
139+
140+
// Reference to internal data cache key
141+
internalKey = jQuery.expando,
142+
143+
isNode = elem.nodeType,
139144

140145
// See jQuery.data for more information
141146
cache = isNode ? jQuery.cache : elem,
@@ -150,9 +155,16 @@ jQuery.extend({
150155
}
151156

152157
if ( name ) {
153-
var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
158+
159+
thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
154160

155161
if ( thisCache ) {
162+
163+
// Support interoperable removal of hyphenated or camelcased keys
164+
if ( !thisCache[ name ] ) {
165+
name = jQuery.camelCase( name );
166+
}
167+
156168
delete thisCache[ name ];
157169

158170
// If there is no data left in the cache, we want to continue

0 commit comments

Comments
 (0)