Skip to content
Permalink
Browse files
Fix #10984. Use origType when unbinding via the event object.
  • Loading branch information
dmethvin committed Dec 14, 2011
1 parent 2a63b98 commit c584ce4f562536a282c6ccfd78d5d12080850517
Showing 2 changed files with 11 additions and 2 deletions.
@@ -922,7 +922,7 @@ jQuery.fn.extend({
// ( event ) dispatched jQuery.Event
var handleObj = types.handleObj;
jQuery( types.delegateTarget ).off(
handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type,
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
handleObj.selector,
handleObj.handler
);
@@ -2521,7 +2521,7 @@ test(".on and .off", function() {
});

test("special bind/delegate name mapping", function() {
expect( 6 );
expect( 7 );

jQuery.event.special.slap = {
bindType: "click",
@@ -2561,6 +2561,8 @@ test("special bind/delegate name mapping", function() {
delegateType: "click",
handle: function( event ) {
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() {
.trigger( "gutfeeling" )
.remove();

// Ensure .one() events are removed after their maiden voyage
jQuery( '<p>Gut Feeling</p>' )

This comment has been minimized.

Copy link
@rwaldron

rwaldron Dec 14, 2011

Member

Double quotes please. kthx <3

.one( "gutfeeling", jQuery.noop )
.trigger( "gutfeeling" ) // This one should
.trigger( "gutfeeling" ) // This one should not
.remove();

delete jQuery.event.special.gutfeeling;
});

2 comments on commit c584ce4

@martin-g
Copy link

@martin-g martin-g commented on c584ce4 Dec 14, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you verify that the second doesn't trigger?

@danheberden
Copy link
Member

@danheberden danheberden commented on c584ce4 Dec 14, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it does trigger, the expect count would be higher, thus failing the test

Please sign in to comment.