jQuery.cache[ id ] && jQuery.cache[ id ][ name ] will return true/ false, not the data. Shouldn't that be
return name && jQuery.cache[ id ] ? jQuery.cache[ id ][ name ] : id; }, ? Maybe this is slower than the current code and that's the reason it is as it is. On Jul 12, 10:04 am, Azat Razetdinov <razetdi...@gmail.com> wrote: > jQuery.data() creates an entry in the cache for a given element even > if the data is only accessed, not stored. As a result, cache gets > polluted with empty redundant objects. A small patch would fix the > problem: > > Index: data.js > =================================================================== > --- data.js (revision 6421) > +++ data.js (working copy) > @@ -14,18 +14,19 @@ > if ( !id ) > id = elem[ expando ] = ++uuid; > > - // Only generate the data cache if we're > - // trying to access or manipulate it > - if ( name && !jQuery.cache[ id ] ) > - jQuery.cache[ id ] = {}; > + // Prevent overriding the named cache with undefined values > + if ( data !== undefined ) { > + // Only generate the data cache if we're > + // trying to manipulate it > + if ( !jQuery.cache[ id ] ) > + jQuery.cache[ id ] = {}; > > - // Prevent overriding the named cache with undefined values > - if ( data !== undefined ) > jQuery.cache[ id ][ name ] = data; > + } > > // Return the named cache data, or the ID for the element > return name ? > - jQuery.cache[ id ][ name ] : > + jQuery.cache[ id ] && jQuery.cache[ id ][ name ] : > id; > }, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---