diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2013-11-11 13:13:22 -0500 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2015-03-04 17:26:47 -0500 |
commit | d702b7637a61e1973e08c27b8d8de2ed24a543e2 (patch) | |
tree | 5facc46a8a1fd855112e851219c6efc1b2206eb3 /src/manipulation.js | |
parent | 95fb798980d7e404c413e29e20016db9052e2bf2 (diff) | |
download | jquery-d702b7637a61e1973e08c27b8d8de2ed24a543e2.tar.gz jquery-d702b7637a61e1973e08c27b8d8de2ed24a543e2.zip |
Data: move element cache to element[expando]
- avoid explicit data.discard() cleanup calls
- explicitly remove the data.events property, only when private data exists
- reduces code footprint
Fixes gh-1734
Close gh-1428
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index 7c9f5049a..be982dc2d 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -288,34 +288,25 @@ jQuery.extend({ }, cleanData: function( elems ) { - var data, elem, type, key, + var data, elem, type, special = jQuery.event.special, i = 0; for ( ; (elem = elems[ i ]) !== undefined; i++ ) { - if ( jQuery.acceptData( elem ) ) { - key = elem[ dataPriv.expando ]; - - if ( key && (data = dataPriv.cache[ key ]) ) { - if ( data.events ) { - for ( type in data.events ) { - if ( special[ type ] ) { - jQuery.event.remove( elem, type ); - - // This is a shortcut to avoid jQuery.event.remove's overhead - } else { - jQuery.removeEvent( elem, type, data.handle ); - } + if ( jQuery.acceptData( elem ) && (data = elem[ dataPriv.expando ])) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); } } - if ( dataPriv.cache[ key ] ) { - // Discard any remaining `private` data - delete dataPriv.cache[ key ]; - } } + delete data.events; } - // Discard any remaining `user` data - delete dataUser.cache[ elem[ dataUser.expando ] ]; } } }); |