mirror of
https://github.com/jquery/jquery.git
synced 2026-02-07 21:05:38 -05:00
Landing pull request 512. 1.7 - removeData now takes space separated lists and arrays of keys - Fixes #7323.
More Details: - https://github.com/jquery/jquery/pull/512 - http://bugs.jquery.com/ticket/7323
This commit is contained in:
21
src/data.js
21
src/data.js
@@ -133,7 +133,7 @@ jQuery.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
var thisCache,
|
||||
var thisCache, i, l,
|
||||
|
||||
// Reference to internal data cache key
|
||||
internalKey = jQuery.expando,
|
||||
@@ -158,12 +158,25 @@ jQuery.extend({
|
||||
|
||||
if ( thisCache ) {
|
||||
|
||||
// Support interoperable removal of hyphenated or camelcased keys
|
||||
if ( !thisCache[ name ] ) {
|
||||
// Support space separated names
|
||||
if ( jQuery.isArray( name ) ) {
|
||||
name = name;
|
||||
} else if ( name in thisCache ) {
|
||||
name = [ name ];
|
||||
} else {
|
||||
|
||||
// split the camel cased version by spaces
|
||||
name = jQuery.camelCase( name );
|
||||
if ( name in thisCache ) {
|
||||
name = [ name ];
|
||||
} else {
|
||||
name = name.split( " " );
|
||||
}
|
||||
}
|
||||
|
||||
delete thisCache[ name ];
|
||||
for ( i = 0, l = name.length; i < l; i++ ) {
|
||||
delete thisCache[ name[i] ];
|
||||
}
|
||||
|
||||
// If there is no data left in the cache, we want to continue
|
||||
// and let the cache object itself get destroyed
|
||||
|
||||
22
src/event.js
22
src/event.js
@@ -238,20 +238,18 @@ jQuery.event = {
|
||||
|
||||
delete events[ type ];
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the expando if it's no longer used
|
||||
if ( jQuery.isEmptyObject( events ) ) {
|
||||
handle = elemData.handle;
|
||||
if ( handle ) {
|
||||
handle.elem = null;
|
||||
}
|
||||
|
||||
delete elemData.events;
|
||||
|
||||
// removeData also checks for emptiness and clears the expando if empty
|
||||
// so use it instead of delete for this last property we touch here
|
||||
jQuery.removeData( elem, "handle", true );
|
||||
// Remove the expando if it's no longer used
|
||||
if ( jQuery.isEmptyObject( events ) ) {
|
||||
handle = elemData.handle;
|
||||
if ( handle ) {
|
||||
handle.elem = null;
|
||||
}
|
||||
|
||||
// removeData also checks for emptiness and clears the expando if empty
|
||||
// so use it instead of delete
|
||||
jQuery.removeData( elem, [ "events", "handle" ], true );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user