Browse files

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

  • Loading branch information...
1 parent 9d07525 commit ff7b7cfd1d754f6daf20541dc71c84ad690d3708 @NikGovorov NikGovorov committed with dmethvin Aug 19, 2012
Showing with 25 additions and 1 deletion.
  1. +1 −0 AUTHORS.txt
  2. +1 −1 src/event.js
  3. +23 −0 test/unit/event.js
View
1 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>
View
2 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 );
}
};
}
View
23 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);

0 comments on commit ff7b7cf

Please sign in to comment.