]> source.dussan.org Git - jquery.git/commitdiff
Fix #12149. Avoid memory leak on oldIE change events. Close gh-878.
authorNikita Govorov <nikita.govorov@gmail.com>
Mon, 20 Aug 2012 00:19:44 +0000 (20:19 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Mon, 20 Aug 2012 00:24:03 +0000 (20:24 -0400)
AUTHORS.txt
src/event.js
test/unit/event.js

index 51200abaf326cf9e6fa4e58848745e62b1e53c52..01c8d76b06748ea5d7afb6346004ef4fe0e44e14 100644 (file)
@@ -130,3 +130,4 @@ Uri Gilad <antishok@gmail.com>
 Chris Faulkner <thefaulkner@gmail.com>
 Elijah Manor <elijah.manor@gmail.com>
 Daniel Chatfield <chatfielddaniel@googlemail.com>
+Nikita Govorov <nikita.govorov@gmail.com>
\ No newline at end of file
index 2a2ea24aa304b5921a34b894c041ba325b0de12d..797f1aaee2ba2ea3d1bdddb0dcb3751d74209588 100644 (file)
@@ -832,7 +832,7 @@ if ( !jQuery.support.changeBubbles ) {
                teardown: function() {
                        jQuery.event.remove( this, "._change" );
 
-                       return rformElems.test( this.nodeName );
+                       return !rformElems.test( this.nodeName );
                }
        };
 }
index 16a9ff0fcfaaf2a4beb901747147017284d666e7..c1981623da568c98091e18aa712fe71107ebddc9 100644 (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() {
        expect(1);