Handle some edge cases with binding events to the window object (which is also a plain object - causing some confusion). Fixes #7143.
This commit is contained in:
parent
c00a6ff1f1
commit
1df5084c97
|
@ -282,7 +282,7 @@ jQuery.event = {
|
||||||
delete elemData.handle;
|
delete elemData.handle;
|
||||||
|
|
||||||
if ( typeof elemData === "function" ) {
|
if ( typeof elemData === "function" ) {
|
||||||
delete elem.events;
|
jQuery.removeData( elem, "events" );
|
||||||
|
|
||||||
} else if ( jQuery.isEmptyObject( elemData ) ) {
|
} else if ( jQuery.isEmptyObject( elemData ) ) {
|
||||||
jQuery.removeData( elem );
|
jQuery.removeData( elem );
|
||||||
|
@ -346,7 +346,7 @@ jQuery.event = {
|
||||||
// Trigger the event, it is assumed that "handle" is a function
|
// Trigger the event, it is assumed that "handle" is a function
|
||||||
var handle = elem.nodeType ?
|
var handle = elem.nodeType ?
|
||||||
jQuery.data( elem, "handle" ) :
|
jQuery.data( elem, "handle" ) :
|
||||||
elem.events && elem.events.handle;
|
(jQuery.data( elem, "events" ) || {}).handle;
|
||||||
|
|
||||||
if ( handle ) {
|
if ( handle ) {
|
||||||
handle.apply( elem, data );
|
handle.apply( elem, data );
|
||||||
|
|
|
@ -1830,11 +1830,15 @@ test("Non DOM element events", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("window resize", function() {
|
test("window resize", function() {
|
||||||
expect(1);
|
expect(2);
|
||||||
|
|
||||||
|
jQuery(window).unbind();
|
||||||
|
|
||||||
jQuery(window).bind("resize", function(){
|
jQuery(window).bind("resize", function(){
|
||||||
ok( true, "Resize event fired." );
|
ok( true, "Resize event fired." );
|
||||||
}).resize().unbind("resize");
|
}).resize().unbind("resize");
|
||||||
|
|
||||||
|
ok( !jQuery(window).data("events"), "Make sure all the events are gone." );
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue