From b85f222df55418c733c9639e88c0cdd5111c585b Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 20 Sep 2011 22:18:34 -0400 Subject: Don't fire change on an already-selected radio. Thanks to Brandon Wallace (@bman654) for his code review. Also tweaks delegatetest.html output. --- src/event.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/event.js') diff --git a/src/event.js b/src/event.js index 28716ad5f..443bf862c 100644 --- a/src/event.js +++ b/src/event.js @@ -764,12 +764,20 @@ if ( !jQuery.support.changeBubbles ) { setup: function() { if ( rformElems.test( this.nodeName ) ) { - // IE doesn't fire change on a checkbox/radio until blur; make it happen - // immediately by triggering our own change event now. - // Avoid double-firing change by eating it in special.change.handle. + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); jQuery.event.add( this, "click._change", function( event ) { - simulate( "change", this, event, true ); + if ( this._just_changed ) { + this._just_changed = false; + simulate( "change", this, event, true ); + } }); } return false; -- cgit v1.2.3