Fix #12149. Avoid memory leak on oldIE change events. Close gh-878.

This commit is contained in:
Nikita Govorov 2012-08-19 20:19:44 -04:00 committed by Dave Methvin
parent 9d07525a71
commit ff7b7cfd1d
3 changed files with 25 additions and 1 deletions

View File

@ -130,3 +130,4 @@ Uri Gilad <antishok@gmail.com>
Chris Faulkner <thefaulkner@gmail.com> Chris Faulkner <thefaulkner@gmail.com>
Elijah Manor <elijah.manor@gmail.com> Elijah Manor <elijah.manor@gmail.com>
Daniel Chatfield <chatfielddaniel@googlemail.com> Daniel Chatfield <chatfielddaniel@googlemail.com>
Nikita Govorov <nikita.govorov@gmail.com>

View File

@ -832,7 +832,7 @@ if ( !jQuery.support.changeBubbles ) {
teardown: function() { teardown: function() {
jQuery.event.remove( this, "._change" ); jQuery.event.remove( this, "._change" );
return rformElems.test( this.nodeName ); return !rformElems.test( this.nodeName );
} }
}; };
} }

View File

@ -2985,6 +2985,29 @@ if ( hasPHP ) {
})(); })();
test("change handler should be detached from element", function() {
expect( 2 );
var $fixture = jQuery( "<input type='text' id='change-ie-leak' />" ).appendTo( "body" );
var originRemoveEvent = jQuery.removeEvent;
var wrapperRemoveEvent = function(elem, type, handle){
equal("change", type, "Event handler for 'change' event should be removed");
equal("change-ie-leak", jQuery(elem).attr("id"), "Event handler for 'change' event should be removed from appropriate element");
originRemoveEvent(elem, type, handle);
};
jQuery.removeEvent = wrapperRemoveEvent ;
$fixture.bind( "change", function( event ) {});
$fixture.unbind( "change" );
$fixture.remove();
jQuery.removeEvent = originRemoveEvent;
});
asyncTest("trigger click on checkbox, fires change event", function() { asyncTest("trigger click on checkbox, fires change event", function() {
expect(1); expect(1);