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 with 11 additions and 2 deletions.
  1. +1 −1 src/event.js
  2. +10 −1 test/unit/event.js
@@ -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

This comment has been minimized.

Copy link

@martin-g martin-g replied Dec 14, 2011

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

@danheberden

This comment has been minimized.

Copy link
Member

@danheberden danheberden replied Dec 14, 2011

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

Please sign in to comment.