Skip to main content

Bug Tracker

Side navigation

#13639 closed bug (invalid)

Opened March 21, 2013 03:39AM UTC

Closed April 05, 2013 09:03AM UTC

Last modified April 05, 2013 01:32PM UTC

Bug with event.stopImmediatePropagation() or documentation

Reported by: t.rainbolt@rogers.com Owned by: t.rainbolt@rogers.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

There is either a bug with (event.stopImmediatePropagation()) or the documentation needs clarification.

1. event.stopImmediatePropagation() does not prevent all handlers from firing. Only handlers of the 'same' type as the handler that called the function.

2. Or you have not specified in the documentation correctly if this is not a bug.

Please review: http://jsfiddle.net/XhqeG/

Attachments (0)
Change History (6)

Changed March 21, 2013 01:49PM UTC by dmethvin comment:1

owner: → t.rainbolt@rogers.com
status: newpending

So what wording would you propose? True to its name, .stopImmediatePropagation() does stop the propagation of the current event so that no other handlers fire. Why would it affect *other* events? The jQuery documentation is generally meant to be used by developers with an understanding of the W3C event model, and there is nothing in the standard about this.

Changed March 21, 2013 02:15PM UTC by t.rainbolt@rogers.com comment:2

status: pendingnew

If I have 2 event handlers and I put a condition in the first one that makes it so the next shouldn't fire [using event.stopImmediatePropagation()] then that's what I expect.

$(this).on('mousedown', function(event){ 
	if( foo == 'bar'){ 
		event.stopImmediatePropagation(); 
	} 
}).on('click', function(event){
	if(foo == 'bar'){
		alert('I should never alert!');
	}
});

FROM THE DOCUMENTATION:

Description: Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree.

This is incorrect. It only keeps handlers of the same event type from being executed.

Changed March 21, 2013 02:21PM UTC by scottgonzalez comment:3

status: newpending

These are two different events that happen to be caused by the same user action. You've stopped the propagation of mousedown, so the rest of the handlers for mousedown do not execute. After mousedown completes, a click event starts. You have not done anything on the click event to stop propagation.

The code is working correctly. You can try the exact same thing with native DOM events.

@dmethvin has asked you what update you would like to see in the wording, but so far you haven't suggested any changes.

Changed March 21, 2013 03:12PM UTC by anonymous comment:4

You said it in your reply.

You've stopped the propagation of

mousedown

This is what is 'not' clear. I'm expecting 'all' handlers from being executed. Clearly it is not stopping 'all,' just all of the same event type.

It should read:

Keeps the rest of the handlers of the same event type from being executed and prevents the event from bubbling up the DOM tree.

Changed April 05, 2013 09:03AM UTC by trac-o-bot comment:5

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Changed April 05, 2013 01:32PM UTC by t.rainbolt@rogers.com comment:6

My comment was added above, however, I forgot to include my email address so it was set to 'anonymous.' Please see above (comment 4).