]> source.dussan.org Git - jquery.git/commitdiff
Handle some edge cases with binding events to the window object (which is also a...
authorJohn Resig <jeresig@gmail.com>
Mon, 11 Oct 2010 22:20:57 +0000 (18:20 -0400)
committerJohn Resig <jeresig@gmail.com>
Mon, 11 Oct 2010 22:20:57 +0000 (18:20 -0400)
src/event.js
test/unit/event.js

index 7a10a12cb182a47e19269668a1c08ce6bed54dd1..d949d0f0f8f5c5bae27ad6cb65fbcddd30c04d52 100644 (file)
@@ -282,7 +282,7 @@ jQuery.event = {
                        delete elemData.handle;
 
                        if ( typeof elemData === "function" ) {
-                               delete elem.events;
+                               jQuery.removeData( elem, "events" );
 
                        } else if ( jQuery.isEmptyObject( elemData ) ) {
                                jQuery.removeData( elem );
@@ -346,7 +346,7 @@ jQuery.event = {
                // Trigger the event, it is assumed that "handle" is a function
                var handle = elem.nodeType ?
                        jQuery.data( elem, "handle" ) :
-                       elem.events && elem.events.handle;
+                       (jQuery.data( elem, "events" ) || {}).handle;
 
                if ( handle ) {
                        handle.apply( elem, data );
index d9dcc97ec0f60b007dc6ffc7dff32d8b7d91a35c..b093e8e71220ff8c01d42ff96f4805c6dd5bb5de 100644 (file)
@@ -1830,11 +1830,15 @@ test("Non DOM element events", function() {
 });
 
 test("window resize", function() {
-       expect(1);
+       expect(2);
+
+       jQuery(window).unbind();
 
        jQuery(window).bind("resize", function(){
                ok( true, "Resize event fired." );
        }).resize().unbind("resize");
+
+       ok( !jQuery(window).data("events"), "Make sure all the events are gone." );
 });
 
 /*