Commit c584ce4f authored by Dave Methvin's avatar Dave Methvin

Fix #10984. Use origType when unbinding via the event object.

parent 2a63b980
...@@ -922,7 +922,7 @@ jQuery.fn.extend({ ...@@ -922,7 +922,7 @@ jQuery.fn.extend({
// ( event ) dispatched jQuery.Event // ( event ) dispatched jQuery.Event
var handleObj = types.handleObj; var handleObj = types.handleObj;
jQuery( types.delegateTarget ).off( jQuery( types.delegateTarget ).off(
handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
handleObj.selector, handleObj.selector,
handleObj.handler handleObj.handler
); );
......
...@@ -2521,7 +2521,7 @@ test(".on and .off", function() { ...@@ -2521,7 +2521,7 @@ test(".on and .off", function() {
}); });
test("special bind/delegate name mapping", function() { test("special bind/delegate name mapping", function() {
expect( 6 ); expect( 7 );
jQuery.event.special.slap = { jQuery.event.special.slap = {
bindType: "click", bindType: "click",
...@@ -2561,6 +2561,8 @@ test("special bind/delegate name mapping", function() { ...@@ -2561,6 +2561,8 @@ test("special bind/delegate name mapping", function() {
delegateType: "click", delegateType: "click",
handle: function( event ) { handle: function( event ) {
equal( event.handleObj.origType, "gutfeeling", "got a gutfeeling" ); equal( event.handleObj.origType, "gutfeeling", "got a gutfeeling" );
// Need to call the handler since .one() uses it to unbind
return event.handleObj.handler.call( this , event );
} }
}; };
...@@ -2579,6 +2581,13 @@ test("special bind/delegate name mapping", function() { ...@@ -2579,6 +2581,13 @@ test("special bind/delegate name mapping", function() {
.trigger( "gutfeeling" ) .trigger( "gutfeeling" )
.remove(); .remove();
// Ensure .one() events are removed after their maiden voyage
jQuery( '<p>Gut Feeling</p>' )
.one( "gutfeeling", jQuery.noop )
.trigger( "gutfeeling" ) // This one should
.trigger( "gutfeeling" ) // This one should not
.remove();
delete jQuery.event.special.gutfeeling; delete jQuery.event.special.gutfeeling;
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment