delete event.delegateTarget;
// Run non-delegated handlers for this level
- if ( handlers.length ) {
+ if ( handlers.length && !event.isPropagationStopped() ) {
dispatch( this, event, handlers, args );
}
jQuery("#body").undelegate("#nothiddendiv div", "click");
});
+test("stopPropagation() stops directly-bound events on delegated target", function() {
+ expect(1);
+
+ var markup = jQuery( '<div><p><a href="#">target</a></p></div>' );
+ markup
+ .on( "click", function() {
+ ok( false, "directly-bound event on delegate target was called" );
+ })
+ .on( "click", "a", function( e ) {
+ e.stopPropagation();
+ ok( true, "delegated handler was called" );
+ })
+ .find("a").click().end()
+ .remove();
+});
+
test("undelegate all bound events", function(){
expect(1);