Skip to content
Permalink
Browse files

Handle some edge cases with binding events to the window object (whic…

…h is also a plain object - causing some confusion). Fixes #7143.
  • Loading branch information...
jeresig committed Oct 11, 2010
1 parent c00a6ff commit 1df5084c9748a8d38516266063344f145bc428c0
Showing with 7 additions and 3 deletions.
  1. +2 −2 src/event.js
  2. +5 −1 test/unit/event.js
@@ -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 );
@@ -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." );
});

/*

0 comments on commit 1df5084

Please sign in to comment.
You can’t perform that action at this time.