diff options
author | Nikita Govorov <nikita.govorov@gmail.com> | 2012-08-19 20:19:44 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-08-19 20:24:03 -0400 |
commit | ff7b7cfd1d754f6daf20541dc71c84ad690d3708 (patch) | |
tree | 9e83a70b4215b260f95f06041b8325e6a3ea72d9 | |
parent | 9d07525a71e7bc12f606d8015d21425c5580e262 (diff) | |
download | jquery-ff7b7cfd1d754f6daf20541dc71c84ad690d3708.tar.gz jquery-ff7b7cfd1d754f6daf20541dc71c84ad690d3708.zip |
Fix #12149. Avoid memory leak on oldIE change events. Close gh-878.
-rw-r--r-- | AUTHORS.txt | 1 | ||||
-rw-r--r-- | src/event.js | 2 | ||||
-rw-r--r-- | test/unit/event.js | 23 |
3 files changed, 25 insertions, 1 deletions
diff --git a/AUTHORS.txt b/AUTHORS.txt index 51200abaf..01c8d76b0 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -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 diff --git a/src/event.js b/src/event.js index 2a2ea24aa..797f1aaee 100644 --- a/src/event.js +++ b/src/event.js @@ -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 ); } }; } diff --git a/test/unit/event.js b/test/unit/event.js index 16a9ff0fc..c1981623d 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -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); |