From d5f144a7bba98212d6fe9e257f722b62baf651f0 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Mon, 19 Sep 2011 16:13:14 -0400 Subject: Landing pull request 500. 1.7 - "public data" stored as a key on "internal data" - Fixes #8921. More Details: - https://github.com/jquery/jquery/pull/500 - http://bugs.jquery.com/ticket/8921 --- src/event.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/event.js') diff --git a/src/event.js b/src/event.js index 363448b60..2617382ad 100644 --- a/src/event.js +++ b/src/event.js @@ -247,11 +247,10 @@ jQuery.event = { } delete elemData.events; - delete elemData.handle; - if ( jQuery.isEmptyObject( elemData ) ) { - jQuery.removeData( elem, undefined, true ); - } + // 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 ); } } }, @@ -326,17 +325,14 @@ jQuery.event = { // Handle a global trigger if ( !elem ) { + // TODO: Stop taunting the data cache; remove global events and always attach to document - jQuery.each( jQuery.cache, function() { - // internalKey variable is just used to make it easier to find - // and potentially change this stuff later; currently it just - // points to jQuery.expando - var internalKey = jQuery.expando, - internalCache = this[ internalKey ]; - if ( internalCache && internalCache.events && internalCache.events[ type ] ) { - jQuery.event.trigger( event, data, internalCache.handle.elem ); + var cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem ); } - }); + } return; } -- cgit v1.2.3